Logo Passei Direto
Buscar
Material

Prévia do material em texto

Chapter 1.2, Problem 13E Step-by-step solution Step 1 of 2 Rearranges all 0's preceding all in an array of bits. Consider an array that contains only 0's and 1's. Rearrange the array so that all of the zeros proceed' all of ones. Now, traverse from both side and keep on swapping the 1 (in front) with 0 (in back). Here, input parameter is and Output parameter is sorted array of bits containing only 1 or 0. Step 2 of 2 Algorithm to sort the array of bits containing only 1 or 0 sort_bits(s) i=1 //Assignj last index in array while(i

Mais conteúdos dessa disciplina