NEW
Font size
Worksheets9.4.25 Mentoring quiz
Total questions: 20
Worksheet time: 23mins
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
print("Hello world!" * 2)
Which paradigm dictates WHAT should be done but not HOW it should be done?
Declarative
Imperative
Object Oriented
Low level
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of the above
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
Choose a correct C Statement.
a++ is (a=a+1) POST INCREMENT Operator
a-- is (a=a-1) POST DECREMENT Operator
--a is (a=a-1) PRE DECREMENT Operator
++a is (a=a+1) PRE INCREMENT Operator
All the above.
In the following loop construct, which one is executed only once always.
for(exp1; exp2; exp3)
exp1
exp3
exp1 and exp3
exp1,exp2 and exp3
What is the value of the postfix expression 6 3 2 4 + – *:
1
14
74
-18
What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order
Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
4
3
2
1
Consider the following definition in c programming language.
struct node { int data; struct node next; }
typedef struct node NODE;
NODE *ptr;
Which of the following c code is used to create new node?
ptr = (NODE*)malloc(sizeof(NODE));
ptr = (NODE*)malloc(NODE);
ptr = (NODE*)malloc(sizeof(NODE*));
ptr = (NODE)malloc(sizeof(NODE));
What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{ if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data); }
Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of Linked List
Prints alternate nodes in reverse order
What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);
if(start->next != NULL )
fun(start->next->next);
printf("%d ", start->data);
}
1 4 6 6 4 1
1 3 5 1 3 5
1 2 3 5
1 3 5 5 3 1
Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -.
The postfix expression for the infix expression
a + b X c – d ^ e ^ f is?
abc X+ def ^^ –
abc X+ def ^^ –
ab+c Xd – e ^f^
-+aXbc^ ^def
After performing these set of operations, what does the final list look contain? InsertFront(10);
InsertFront(20);
InsertRear(30);
DeleteFront();
InsertRear(40);
InsertRear(10);
DeleteRear();
InsertRear(15);
display();
10 30 10 15
20 30 40 15
20 30 40 15
20 30 40 15
Convert the following infix expressions into its equivalent postfix expressions.
(A + B ⋀D)/(E – F)+G
(A B D ⋀ + E F – / G +)
(A B D +⋀ E F – / G +)
(A B D ⋀ + E F/- G +)
(A B D E F + ⋀ / – G +)
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution?
struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node p, q;
int temp;
if ((!list) || !list->next)
return;
p = list;
q = list->next;
while(q)
{
temp = p->value;
p->value = q->value;
q->value = temp;
p = q->next;
q = p?p->next:0;
}
}
1,2,3,4,5,6,7
2,1,4,3,6,5,7
1,3,2,5,4,7,6
2,3,4,5,6,7,1
Consider the function f defined below.
struct item
{
int data;
struct item * next;
};
int f(struct item *p)
{
return (
(p == NULL) ||
(p->next == NULL) ||
(( P->data <= p->next->data) && f(p->next))
);
}
not all elements in the list have the same data value
the elements in the list are sorted in non-decreasing order of data value
the elements in the list are sorted in non-increasing order of data value
None of them
Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node x from the list?
O(n)
O(log2 n)
O(logn)
O(1)
