41. Consider the following iterative implementation used to find the length of a linked list:
struct Node
{
int val;
struct Node *next;
}*head;
int get_len()
{
struct Node *temp = head->next;
int len = 0;
while(_____)
{
len++;
temp = temp->next;
}
return len;
}
Which of the following conditions should be checked to complete the above code?
struct Node
{
int val;
struct Node *next;
}*head;
int get_len()
{
struct Node *temp = head->next;
int len = 0;
while(_____)
{
len++;
temp = temp->next;
}
return len;
}
Which of the following conditions should be checked to complete the above code?42. What is the output of the following code?
#include<stdio.h>
int arr[31], len = 0;
void recursive_dec_to_bin(int n)
{
if(n == 0 && len == 0)
{
arr[len++] = 0;
return;
}
if(n == 0)
return;
arr[len++] = n % 2;
recursive_dec_to_bin(n/2);
}
int main()
{
int n = -100,i;
recursive_dec_to_bin(n);
for(i=len-1; i>=0; i--)
printf("%d",arr[i]);
return 0;
}
#include<stdio.h>
int arr[31], len = 0;
void recursive_dec_to_bin(int n)
{
if(n == 0 && len == 0)
{
arr[len++] = 0;
return;
}
if(n == 0)
return;
arr[len++] = n % 2;
recursive_dec_to_bin(n/2);
}
int main()
{
int n = -100,i;
recursive_dec_to_bin(n);
for(i=len-1; i>=0; i--)
printf("%d",arr[i]);
return 0;
}
43. The pendant vertex of the graph can also be an articulation point of the graph.
44. Consider the following recursive implementation to find the nth fibonnaci number:
int fibo(int n)
{
if(n == 1)
return 0;
else if(n == 2)
return 1;
return fibo(n - 1) + fibo(n - 2);
}
int main()
{
int n = 5;
int ans = fibo(n);
printf("%d",ans);
return 0;
}
Which of the following is the base case?
int fibo(int n)
{
if(n == 1)
return 0;
else if(n == 2)
return 1;
return fibo(n - 1) + fibo(n - 2);
}
int main()
{
int n = 5;
int ans = fibo(n);
printf("%d",ans);
return 0;
}
Which of the following is the base case?45. For how many queens was the extended version of Eight Queen Puzzle applicable for n*n squares?
46. Consider the following iterative code used to convert a decimal number to its equivalent binary:
#include<stdio.h>
void dec_to_bin(int n)
{
int arr[31],len = 0,i;
if(n == 0)
{
arr[0] = 0;
len = 1;
}
while(n != 0)
{
arr[len++] = n % 2;
_______;
}
for(i=len-1; i>=0; i--)
printf("%d",arr[i]);
}
int main()
{
int n = 10;
dec_to_bin(n);
return 0;
}
Which of the following lines should be inserted to complete the above code?
#include<stdio.h>
void dec_to_bin(int n)
{
int arr[31],len = 0,i;
if(n == 0)
{
arr[0] = 0;
len = 1;
}
while(n != 0)
{
arr[len++] = n % 2;
_______;
}
for(i=len-1; i>=0; i--)
printf("%d",arr[i]);
}
int main()
{
int n = 10;
dec_to_bin(n);
return 0;
}
Which of the following lines should be inserted to complete the above code?47. In which of the following cipher the plain text and the ciphered text does not have the same set of letters?
48. What will be the ciphered text if rail fence cipher is used for encrypting the plain text "EXAMPLE" with the key value given to be 2?
49. Polybius square cipher is most closely related to?
50. Consider the following pseudocode for the random page replacement algorithm. Which of the following best suits the blank?
Start traversing the pages
if pages < capacity
{
insert the pages until the size of the set reaches capacity or all the pages are processed
maintain the pages in a queue
increment page fault
}
else if
{
current page is present in the set
do nothing
}
else
{
replace the current page with __________
store current page in the queue
increment page fault
}
return page faults
Start traversing the pages
if pages < capacity
{
insert the pages until the size of the set reaches capacity or all the pages are processed
maintain the pages in a queue
increment page fault
}
else if
{
current page is present in the set
do nothing
}
else
{
replace the current page with __________
store current page in the queue
increment page fault
}
return page faults
Read More Section(Miscellaneous on Data Structures)
Each Section contains maximum 100 MCQs question on Miscellaneous on Data Structures. To get more questions visit other sections.
- Miscellaneous on Data Structures - Section 1
- Miscellaneous on Data Structures - Section 2
- Miscellaneous on Data Structures - Section 3
- Miscellaneous on Data Structures - Section 4
- Miscellaneous on Data Structures - Section 6
- Miscellaneous on Data Structures - Section 7
- Miscellaneous on Data Structures - Section 8
- Miscellaneous on Data Structures - Section 9
- Miscellaneous on Data Structures - Section 10
- Miscellaneous on Data Structures - Section 11
- Miscellaneous on Data Structures - Section 12