Font size
WorksheetsData Structures and Algorithms
Total questions: 100
Worksheet time: 59mins
Efficiency of an algorithm is measured by
Time and Capacity complexity
Time and Space complexity
Speed and Space complexity
Speed and Capacity complexity
A container that can hold a fixed number of items and these items should be of the same type.
Element
Array
Index
What is an algorithm?
Patterns and trends used to solve a problem
A set of step-by-step instructions to resolve a problem
A programming language
How can an algorithm be represented?
As a flowchart only
As pseudocode only
As a flowchart or pseudocode
Which of these is not a data structure?
Stack
Array
Integer
List
Data Structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
True
False
Example of Non-linear data structure.
array
tree
queue
stack
If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
Act of adding values into a stack is called
Popping
Polling
Pushing
None
Which of these data structures is LIFO?
Stack
Queue
Binary Tree
Double linked list
It is a type of queue where elements are processed based on their order either natural or custom.
Priority Queue
Array List
Min Heap
Max Heap
Which of the following creates an empty set in Java?
a = set()
Set a = new HashSet ();
A = set [ ]
Set a = new TreeSet ();
Which statement determine whether a map contains the value "Pre-final" with the PF identifier?
thisMap.containsKey("Pre-final");
thisMap.containsValue("PF");
thisMap.containsKey("PF");
thisMap.containsValue("Prefinal");
It is a complete binary tree where the value of each parent node is either higher or lower than the value of its child nodes.
Priority Queue
Heap
Array List
Queue
Priority Queues can be implemented in Java using the PriorityQueue class from the ___________ package.
java.scanner
Java.io
java.linkedlist
java.util
A collection of elements where each element is unique.
HashSet
TreeSet
Set
LinkedHashSet
This stores its elements in a hash table without a guaranteed order upon iteration.
Set
HashSet
TreeSet
LinkedHashSet
This stores its elements in a special type of tree where elements are sorted either natural or custom during iteration.
LinkedHashSet
TreeSet
HashSet
Set
A set of ordered pairs where elements are known as keys or identifiers and values or content.
Set
Map
Priority Queue
Array List
A map can contain duplicate keys.
True
False
Each key can map to several values.
True
False
Maps in Python are known as dictionaries.
True
False
Which statement maps the value "Pre-final" to the identifier named PF?
thisMap.put("PF", "Pre-final");
thisMap.put("Pre-final", "PF");
thisMap.add("Pre-final", "PF");
thisMap.add("PF", "Pre-final");
Based on the following statements, which are the leaf nodes?
ArrayList<Integer> minHeap = new ArrayList<>();
Collections.addAll(minHeap, 2, 4, 5, 7, 8);
5, 7, and 8
4, 5, and 7
2, 4, and 5
7 and 8
Set A = { 1, 3, 5, 7 }
Set B = { 2, 3, 4, 5 }
The difference of sets A and B (A - B) is _______?
{ 3}
{ 5 }
{ 1, 7 }
{ 3, 5}
The number of edges from the node to the deepest leaf is called ___ of the tree.
Height
Depth
Length
Width
What is a full binary tree?
Each node has exactly zero or two children
Each node has exactly two children
All the leaves are at the same level
Each node has exactly one or two children
What is a complete binary tree?
Each node has exactly zero or two children
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
A tree In which all nodes have degree 2
Which of the following is not an advantage of trees?
Hierarchical structure
Faster search
Router algorithms
Undo/Redo operations in a notepad
In a full binary tree if number of internal nodes is I, then number of leaves L are?
L = 2*I
L = I + 1
L = I – 1
L = 2*I – 1
Which of the following highly uses the concept of an array?
Binary Search tree
Caching
Spatial locality
Scheduling of Processes
Any node is the path from the root to the node is called
Successor node
Ancestor node
Internal node
None of the above
Which of the following options is not true about the Binary Search tree?
The value of the left child should be less than the root node
The value of the right child should be greater than the root node
The left and right sub trees should also be a binary search tree
None of the above
What is the maximum number of children that a node can have in a binary tree?
3
1
4
2
The maximum number of nodes in a binary tree of depth 5 is
31
16
32
15
In a min-heap:
parent nodes have values greater than or equal to their Childs
parent nodes have values less than or equal to their Childs
both statements are true
both statements are wrong
n elements of a Queue are to be reversed using another queue. The number of "ADD" and "REMOVE"operations required to do so is:
2*n
4*n
n
The task cannot be accomplished
To perform level-order traversal on a binary tree, which of the
following data structure will be required?
Hash table
Queue
Binary search tree
Stack
If two trees have same structure and but different node content,
then they are called
Synonyms trees
Joint trees
Equivalent trees
Similar trees
If two trees have same structure and node content, then they are
called
Synonyms trees
Joint trees
Equivalent trees
Similar trees
Which of the following is non-liner data structure?
Stacks
List
Strings
Trees
To represent hierarchical relationship between elements, which data structure is suitable?
Dequeue
Priority
Tree
Graph
The no of external nodes in a full binary tree with n internal nodes is?
n
n+1
2n
2n+1
A Binary Tree can have
Can have 2 children
Can have 1 children
Can have 0 children
All of the above
The number of edges from the root to the node is called ____ of the tree.
Height
Depth
Length
Width
Which of this pseudocode statement assigns a value to a variable?
car <- bmw
car is bmw
car == bmw
bmw -> car
Which of this is a valid variable name?
111abc
abc111
abc 111
abc111!
What is the difference between / and % operator?
% operator gives the 'Quotient' from a division operation
AND
/ operator gives the 'Remainder' value from a division operation
/ operator gives the 'Quotient' from a division operation
AND
% operator gives the 'Remainder' value from a division operation
Both / and % operators are the same
A Data Structure is:
A C++ vector
A way of organizing, storing and performing operations on data.
A function in any programming language
A sequence of steps to solve a problem.
Which one is not a data structure?.
Graph
Index
Binary Tree
Record
Which C++ Abstract Data Type is similar to a record?.
Graph
Function
Struct
Enum
An Algorithm is:
The process to transform the design into code.
Braking a large problem into smaller ones
A list of steps needed to solve a problem
None of the above.
Is the Data Structure used irrelevant for the creation of a program?.
Yes
No
A list is:
An ADT for storing items in which the order does not matter and duplicate items are allowed.
An ADT for a collection of distinct items
An ADT in which items are only inserted on or removed from the top of the stack.
An ADT for holding ordered data
Computational Complexity is:
The amount of resources used by the algorithm.
The amount of time taken by an algorithm.
The amount of electricity used by an algorithm.
The amount of bytes included in the algorithm.
The efficiency of an algorithm is measured by:
The run-time of the program.
The length of the algorithm.
The computational complexity of the algorithm.
The speed of the CPU
Abstraction means:
Is an art type.
An object that is hidden from the end user.
A data type that only can be accessed by the developer.
To have a user interact with an item at a high-level, with lower-level internal details hidden from the user.
Does Abstracts Data Types support the programmer's efficiency?.
Yes
No
What is an array?
A linear collection of data elements with random access
A linear collection of data elements with consecutive storage
A dynamic data structure with elements stored in random locations
A collection of linked nodes with consecutive storage
How is memory allocated for a node in a linked list using malloc?
malloc(sizeof(struct node))
malloc(sizeof(struct node*)
malloc(sizeof(struct node) + sizeof(struct node*)
malloc(sizeof(struct node*) + sizeof(struct node)
What is the purpose of the head pointer in a linked list?
To point to the last node in the list
To track the first element in the linked list
To store the size of the linked list
To allow random access of data in the linked list
Which type of linked list allows elements to be added or removed from the middle of the list?
Singly Linked List
Doubly Linked List
Circular Linked List
All of the above
What is a memory leak in dynamic memory allocation?
Allocating memory without using malloc
Not deallocating memory using free
Allocating too much memory using malloc
Deallocating memory multiple times using free
Which function is used to deallocate memory in dynamic memory allocation?
release()
deallocate()
free()
clear()
What is the main advantage of a linked list over an array?
Random access of elements
Efficient memory usage
Fixed size
Limited insertion and deletion operations
Which type of linked list is both singly linked and doubly linked?
Singly Linked List
Doubly Linked List
Circular Linked List
All of the above
How is a new node inserted at the beginning of a singly linked list?
Update the next pointer of the new node to point to the current head of the list
Set the head pointer of the linked list to point to the newly created node.
Allocate space for the new node with malloc
All of the above
In a singly linked list, how is the insertion at the end performed when there is at least one node in the list?
temp->next = ptr; ptr->next = NULL;
ptr->next = temp; temp->next = NULL;
temp = ptr; ptr->next = NULL;
temp->next = NULL; ptr->next = temp;
How is deletion performed in a singly linked list at the beginning?
Set `head` to `NULL` and free the pointer pointing to the head node.
Move `head` to the next node and free the pointer pointing to the original head.
Free the pointer pointing to the head node and set `head` to `NULL`
Move `head` to the next node and set the next of the original head to `NULL
How is searching performed in a singly linked list?
All of the above.
By comparing the data of each node with the specified element.
By using a binary search algorithm.
By checking the next pointers of each node.
How would you count the number of nodes in a singly linked list using recursion?
return countnode(st->next);
return countnode(st->next) - 1;
return countnode(st) + 1;
return countnode(st) - 1;
In traversing a singly linked list, what is the purpose of the `ptr` pointer?
To point to the last node.
To points to the node that is currently being accessed.
To keep track of the head node.
To count the number of nodes.
What is the main difference between a singly linked list and a doubly linked list?
Singly linked lists have a next pointer, while doubly linked lists have both next and previous pointers.
Singly linked lists are dynamic, while doubly linked lists are static.
Singly linked lists allow random access, while doubly linked lists do not.
Singly linked lists store data in consecutive memory locations, unlike doubly linked lists.
Example of linear data structure except
array
tree
queue
stack
Which of these data structures is LIFO?
Stack
Queue
Binary Tree
Double linked list
int nums[ ] =
{2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums
nums[8]
nums[3]
nums(4)
nums(3)
A FIFO structure implemented as a ring where the front and rear pointers can wrap around the end of the start of the array.
Linear Queue
Circular Queue
Priority Queue
It use pointer to link nodes.
Variable
Link List
Pointer
Trees
LIFO stands for
List of Outputs
Last in First Out
First in Last Out
None of them
Act of adding values into a stack is called
Popping
Polling
Pushing
None
If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
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);
After the completion of all operation, get the total number of element present in stack is
1
2
3
4
circular linked list
linked list
doubly circular linked list
doubly linked list
Test Driven Development (TDD) is a part of ____________.
extreme programming
Spiral Model
Halstead Software Science
COCOMO
In Halstead theory of software science, volume is measured in bits. The bits are
Number of bits required to store the program
Actual size of a program if a uniform binary encoding scheme for vocabulary is used
Number of bits required to execute the program
Average Manning
In which one of the following types of coupling, complete data structures are passed from one module to another?
Control Coupling
Stamp Coupling
External Coupling
Content Coupling
Which one of the following is the correct ordering of the coupling of modules from strongest (least desirable) to weakest (most desirable)?
content, common, control, stamp, data
common, content, control, stamp, data
content, data, common ,stamp, common
data, control, common, stamp, content
During the detailed design of a module, which one of the following is designed?
Data structures and algorithms
Control structure
Data flow structure
Module interfaces
A data flow diagram represents which one of the following?
The conditions based on which data items may be processed
The order in which different activities are carried out
The transformation of data through processing stations
The order in which various functions of a program are invoked
Consider the sentence: A book has one or more pages. Which of the following best characterizes the relationship between the Book class and the Page class?
Inheritance
Specialization
Association
Composition
Which one of the following characteristics of a class implies that the same message can be interpreted by it differently.
Encapsulation
Polymorphism
Information Hiding
Inheritance
________________ illustrate the dynamic nature of a system by modeling the flow of control form activity to activity.
Activity Diagram
Sequence Diagram
State chart Diagram
Class Diagram
Temporal cohesion means
Cohesion between temporary variables
Cohesion between local variable
Cohesion with respect to time
Coincidental cohesion
