1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What would be the time complexity to add a node at the end of singly linked list, if the is only a pointer is pointing to the head of the list (there is no pointer to the last element)?
Select one:
a. O(1)
b. O(logn)
c. O(n^2)
d. O(n)
d. O(n)
What would be the time complexity to find an element in the sorted linked list?
Select one:
a. O(logn)
b. O(n)
c. O(1)
d. O(n²)
a. O(logn)
What would be the time complexity to insert an element at the second position in the linked list?
Select one:
a. O(1)
b. None of the mentioned
c. O(n)
d. O(n²)
a. O(1)
What kind of list is best to answer question like "What is the item at position k?"
Select one:
a. Singly linked list
b. Array implementation of list
c. Doubly linked list
d. Circular linked list
b. Array implementation of list
Linked lists are not suitable to for the implementation of?
Select one:
a. Insertion sort
b. Binary search
c. selection sort
d. Polynomial manipulation
b. Binary search
You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?
Select one:
a. Insert a new element as a first element
b. Delete the first element
c. Add a new element at the end of the list
d. Delete the last element of the list
d. Delete the last element of the list
What is the time complexity of inserting at the end in dynamic arrays?
a. O(n)
b. O(logn)
c. Either O(1) or O(n)
d. O(1)
(c) Either O(1) or O(n).
What is the time complexity to count the number of elements in the linked list?
a. O(logn)
b. O(n)
c. O(1)
d. None of the mentioned
b. O(n)
Which of the following is false about a doubly linked list?
a. The insertion and deletion of a node take a bit longer
b. We can navigate in both the directions
c. None of the mentioned
d. It requires more space than a singly linked list
c. None of the mentioned
Which of the following application makes use of a circular linked list?
Select one:
a. Undo operation in a text editor
b. All of the mentioned
c. Allocating CPU to running applications
d. Recursive function calls
c. Allocating CPU to running applications
Which of the following real world scenarios would you associate with a stack data structure?
a. offer services based on the priority of the customer
b. all of the mentioned
c. piling up of chairs one above the other
d. people standing in a line to be serviced at a counter
c. piling up of chairs one above the other
What does "stack underflow" refer to?
Select one:
a. accessing item from an undefined stack
b. adding items to a full stack
c. removing items from an empty stack
d. index out of bounds exception
c. removing items from an empty stack
What is the time complexity of pop() operation when the stack is implemented using an array?
Select one:
a. O(nlogn)
b. O(1)
c. O(n)
d. O(logn)
b. O(1)
Which of the following array position will be occupied by a new element being pushed for a stack of size N elements(capacity of stack > N).
Select one:
a. S[O].
b. S[N].
c. S[N-1].
d. S[1].
b. S[N].
What does "stack overflow" refer to?
Select one:
a. adding items to a full stack
b. index out of bounds exception
c. removing items from an empty stack
d. accessing item from an undefined stack
(a) adding items to a full stack.
Consider these functions:
push(): push an element into the stack
pop(): pop the top-of-the-stack element
top(): returns the item stored in top-of-the-stack-node
What will be the output after performing these sequence of operations
push (20);
push (4);
top ();
pop ();
pop ();
push (5);
top ();
Select one:
a. stack underflow
b. 5
c. 4
d. 20
b. 5
Which of the following properties is associated with a queue?
a. First In First Out
b. First In Last Out
c. None of the mentioned
d. Last In First Out
(a) First In First Out (FIFO).
In linked list implementation of a queue, where does a new element be inserted?
Select one:
a. At the head of link list
b. At the tail of the link list
c. At the centre position in the link list
d. None of the mentioned
b. At the tail of the link list
In linked list implementation of a queue, front and rear pointers are tracked (front = head, rear = tail). Which of these pointers will change during an insertion into a NONEMPTY queue?
Select one:
a. Only rear pointer
b. Both front and rear pointer
c. Only front pointer
d. None of the mentioned
a. Only rear pointer
In linked list implementation of a queue, front and rear pointers are tracked (front = head, rear = tail). Which of these pointers will change during an insertion into EMPTY queue?
Select one:
a. Both front and rear pointer
b. None of the mentioned
c. Only rear pointer
d. Only front pointer
a. Both front and rear pointer
In linked list implementation of a queue, from where is the item dequeued?
a. At the tail of the link list
b. None of the mentioned
c. At the centre position in the link list
d. At the head of link list
(d) At the head of the linked list.
Recursion is a method in which the solution of a problem depends on
Select one:
a. Smaller instances of the same problem
b. Larger instances of different problems
c. Larger instances of the same problem
d. Smaller instances of different problems
(a) Smaller instances of the same problem.
In recursion, the condition for which the function will stop calling itself is
Select one:
a. Best case
b. There is no such condition
c. Worst case
d. Base case
(d) Base case.
Consider the following code snippet:
void my_recursive_function ()
{
Not yet answered
Marked out of 1.00
}
my_recursive_function ();
Flag question
int main()
{
my_recursive_function();
return 0;
}
What will happen when the above snippet is executed?
Select one:
a. The code will be executed successfully and random output will be generated
b. The code will be executed successfully and no output will be generated
c. The code will show a compile time error
d. The code will run for some time and stop when the stack overflows
d. The code will run for some time and stop when the stack overflows
What is the output of the following code?
void my_recursive_function(int n)
{
if (n == 0)
return;
printf("%d ",n);
my_recursive_function (n-1);
}
int main()
{
my_recursive_function (5);
return 0;
}
Select one:
a. 1
b. 543212345
c. 5
d. 54321
d. 54321
What is the base case for the following code?
void my_recursive_function (int n)
{
Not yet answered
if (n == 0)
return;
printf("%d",n);
my_recursive_function (n-1);
}
int main()
{
my_recursive function (10);
return 0;
}
Select one:
a. if(n == 0)
b. my_recursive_function(n-1)
c. return
d. printf("%d", n)
a. if(n == 0)
How many times is the recursive function called, when the following code is
executed?
{
void my_recursive_function (int n)
if (n == 0)
return;
printf("%d ",n);
my_recursive_function (n-1);
}
int main()
{
my_recursive_function (10);
return 0;
}
Select one:
a. 10
b. 9
c. 12
d. 11
d. 11
What does the following recursive code do?
void my_recursive_function(int n)
{
if (n == 0)
Marked out of 1.00
return;
my_recursive_function (n-1);
printf("%d",n);
}
int main()
{
my_recursive_function (10);
return 0;
}
Select one:
a. Prints the numbers from 10 to 0
b. Prints the numbers from 0 to 10
c. Prints the numbers from 1 to 10
d. Prints the numbers from 10 to 1
c. Prints the numbers from 1 to 10
Which of the following statements is true?
Select one:
a. Recursion uses more memory compared to iteration
b. Recursion is always better than iteration
c. Recursion uses less memory compared to iteration
d. Iteration is always better and simpler than recursion
(a) Recursion uses more memory compared to iteration.
What will be the output of the following code?
#include
int cnt=0;
void my_recursive_function (int n)
{
if (n == 0)
return;
cnt++;
my_recursive_function (n/10);
}
int main()
{
my_recursive_function (123456789);
printf("%d", cnt);
return 0;
}
Select one:
a. 10
b. 123456789
c. 0
d. 9
d. 9
What is the output of the following code?
#include
int main()
{
int n;
n=f1 (4);
printf("%d",n);
return (0);
}
int fl(int x)
{ int b;
if (x==1)
return 1;
else
b=x*fl (x-1);
return b;
}
Select one:
a. 4
b. 12
c. 24
d. 10
c. 24
The data structure used to implement recursive function calls
Select one:
a. Binary tree
b. Stack
c. Array
d. Linked list
b. Stack
What happens when the code shown below is executed?
#include
int main()
{
printf("Hello");
main();
return 0;
}
Select one:
a. Hello is printed infinite number of times
b. Hello is printed once
c. O is returned
d. Hello is not printed at all
a. Hello is printed infinite number of times.
What does the following function do?
public void func (Node p)
{
if (p==null) return;
Marked out of 1.00
func (p.left());
func (p.right());
}
System.out.println (p.info);
Select one:
a. Pre-order traversal with the tree with root p
b. Level-order traversal with the tree with root p
c. Post-order traversal with the tree with root p
d. In-order traversal with the tree with root p
(c) Post-order traversal with the tree with root p.
Figure below is a balanced binary tree. If a node inserted as child of the node R, how many nodes will become unbalanced?
a) 2
b) 1
c) 3
d) 0
b. 1
A binary tree is balanced if the difference between left and right subtree of every node is not more than
Select one:
a. 3
b. 1
c. 0
d. 2
b. 1
Which of following figures is a height-balanced binary tree?
Select one:
H là gốc
Balanced binary tree with n items allows the lookup of an item in ______ worst-case time.
Select one:
a. O(2)
b. O(log n)
c. O(1)
d. O(n)
(b) O(log n).
Which of the below diagrams is/are AVL tree/s?
b) only i and ii
In a max-heap, element with the greatest key is always in the which node?
Select one:
a. Leaf node
b. root node
c. First node of left sub tree
d. First node of right sub tree
b. root node
What is the complexity of adding an element to the heap?
a. O(nlogn)
b. O(1)
c. O(n)
d. O(logn)
(d) O(log n).
The complexity of deleting any arbitrary node value element from heap is
Select one:
the. O(logn)
b. O(nlogn)
c. O(n²)
d. O(n)
(a) O(log n).
Heap can be used as
a. A decreasing order array
b. Stack
c. None of the mentioned
d. priority queue
(d) priority queue.
What will be the value in the root after deleting root node (value 1) and
rearranging the heap?
Select one:
a. 17
b. 3
c. 100
d. 2
d.2
Giải thích: Khi nút gốc bị xóa và nút có giá trị 100 được sử dụng làm nút thay thế. Có một sự vi phạm thuộc tính mà nút gốc phải có giá trị nhỏ hơn các nút con của nó. Vì vậy, sẽ có sự xáo trộn của nút có giá trị 100 với nút có giá trị 2. Và do đó, 2 trở thành gốc. Và nó sẽ vẫn ở gốc sau tất cả các hoạt động có thể. Vì vậy, giá trị ở gốc sẽ là 2.
Which are the cut-vertices in the graph below:
Select one:
a. A and E
b. C and D
c. C and B
d. B and E
For a given graph G having n vertices and m edges which is connected and has no cycles, which of the following statements is true?
Select one:
a. None of the mentioned
b. m=n-1
c. m = n+1
d. m = n
(b) m = n - 1.
Which of the following ways can be used to represent a graph?
Select one:
a. Incidence Matrix
b. Adjacency List and Adjacency Matrix
c. None of the mentioned
d. Adjacency List, Adjacency Matrix as well as Incidence Matrix
d. Adjacency List, Adjacency Matrix as well as Incidence Matrix.
For an undirected graph G with n vertices and m edges, the sum of the degrees of each vertex is
Select one:
a. 2m
b. nm
Oc. 2n
d. e^n
(a) 2m.
Graph traversal is different from a tree traversal, because:
a. trees have root
b. graphs may have loops
c. trees are not connected
d. None of mentioned
(b) graphs may have loops.
The spanning tree of connected graph with 10 vertices contains
Select one:
a. 10 edges
b. 9 edges
c. 11 edges
d. 9 vertices
(b) 9 edges.