# 3i Infotech Papers: Sample Questions 181 - 182 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

## Question number: 181

Essay Question▾

### Describe in Detail

1. `void main ()`
2. `{`
3. `    char * s = “12345s ”;`
4. `    printf ( “%d”, sizeof (s) );`
5. `}`

### Explanation

• In the progam

 char * s = “12345s ”; Define the character pointer s and its value printf (“%d”, sizeof (s) ); Printf prints the size of s in bytes, remember s is the pointer
• For a 32 bit computer, the pointer size is 4 bytes

• 64 bit computers have 8 byte pointer size, however, a 64bit computer running a 32bit OS will have 4 byte pointer.

• Thus, under a specific architecture, all types of pointers (void*, int*, char*, long * etc) will have same size (except function pointers).

## Question number: 182

Essay Question▾

### Describe in Detail

What is your favourite sorting algorithm? Why?

### Explanation

• Bubble sort is a good simple algorithm.

• Not suitable for large data sets as its average and worst-case complexity are of where n is the number of items.

• Beautiful algorithm easy to visualize with sorted elements bubbling up.

Bubble sort:

• Let’s solve unsorted array: Image of the Sorting Algorithm 1 Image of the sorting algorithm
• 1st Iteration:

• Start with two elements, comparing them to check which one is greater. Image of the Sorting Algorithm 2 Image of the sorting algorithm
• Value 33 is greater than 14

• Therefore, they are in sorted locations.

• We compare 33 with 27. Image of the Sorting Algorithm 3 Image of the sorting algorithm
• New array looks like Image of the Sorting Algorithm 4 Image of the sorting algorithm
• Compare 33 and 35.

• Both are in sorted positions. Image of the Sorting Algorithm 5 Image of the sorting algorithm
• The next two values, 35 and 10 Image of the Sorting Algorithm 6 Image of the sorting algorithm
• 10 is smaller then 35 and hence are not sorted. Image of the Sorting Algorithm 7 Image of the sorting algorithm
• Swap values.

• We find that we reached the end of the array. Image of the Sorting Algorithm 8 Image of the sorting algorithm
• We are showing how an array should looks like each iteration. One iteration brought 35 to its correct location it bubbled to the top

• After the second iteration. Image of the Sorting Algorithm 9 Image of the sorting algorithm
• After each iteration, one value moves to correct position. Image of the Sorting Algorithm 10 Image of the sorting algorithm
• When no swap is required, bubble sort learns that array is completely sorted. Image of the Sorting Algorithm 11 Image of the sorting algorithm