Font size
WorksheetsActivity 3.1 - Data Structures and Algorithms
Total questions: 85
Worksheet time: 3hrs 50mins
If for an algorithm time complexity is given by O(n) then complexity of it is:
linear
exponential
constant
none of the mentioned
Data in the data structures are processed by operations like insertion, deletion, sorting, merging and ______________
A. Traversing
B. Searching
C. Retrieval
D. Both A and B
If the insertion and deletion happens from both the ends then the deletion is called a ______
Deque
Enqueue
peek
full
Process of inserting an element in stack is called
Insert
Pop
Overflow
Push
If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?
CBA
ABDC
ABCD
DCAB
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 alternate nodes of Linked List
Prints all nodes of linked list in reverse order
Prints alternate nodes in reverse order
. Match the following.
a) Completeness i) How long does it take to find a solution
b) Time Complexity ii) How much memory need to perform the search.
c) Space Complexity iii) Is the strategy guaranteed to find the solution when there in one.
a-iii, b-i, c-ii
a-i, b-ii, c-iii
a-i, b-iii, c-ii
a-iii, b-ii, c-i
Efficiency of an algorithm is measured by
Time and Space complexity
Speed and Capacity complexity
Speed and Space complexity
Time and Capacity complexity
Which of the following data structures are mutable?
Array
List
Tuple
Enum
The algorithm implemented in a stack is?
FIFO- the first element must come out first from the list
WIFI - the worst element must be the first to come in to the list
LIFO - the last element must be the first to come out from the list
all of the above
What will happen by attempting to push another item onto the top of a full stack?
Underflow error
Overload error
Overflow error
Catastrophic error
Look at the diagram of the stack. What would the stack look like after the following operations were called:
peek()
pop()
push("yellow")
It refers to collection of variables, possibly of several different data types connected in various ways.
Database
Arrays
Data Structures
Abstraction
there are primitive data types, meanwhile there are what we call abstract data type, evaluate which is not one.
Stacks
Arrays
Trees
Tables
Data that a variable can hold in a programming language, all programming language has a set of it.
Algorithms
Variables
Data Types
Programming
Finite set of instructions that specify a sequence of operations to be carried out
Flowcharting
Algorithms
Procedure
Pseudocodes
Linear Search checks every element of a list one at a time in sequence, also called as sequential search.
MAYBE
TRUE
FALSE
None of the Choices
It is a mathematical object which arises in many physical problems, consists of m rows and n columns
Array
Matrix
Table
Excel
Which of the following definitions of Array Terms is CORRECT?
Elements - individual data / items in an array indicated by the array name followed by its dimensions appears in a square brackets
Index - each variable or cell in an array
Dimensions - an integer from 1 - n called dimensioned variables
All of the Choices
Which of the following statements is NOT TRUE about PSEUDOCODES?
textual presentation of a flowchart
the control structures impose the logic
close to a natural language
None of the choices
It can be used to encapsulate parts of an algorithm by localizing in one section of a program all the statements relevant to a certain aspect of a program.
Algorithms
Pseudocodes
Flowcharting
Procedures
What is returned by values[5]?
6
9
8
12
Which of these data structures is FIFO?
Stack
Queue
Graph
Linked list
A Queue can only store 6 data items. The Queue has sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?
0
1
2
3
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" pointer point?
0
1
2
3
A Queue can only store 6 data items. The Queue has sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point if a deQueue operation is performed.
Bert
Cynthia
Cedric
Albert
In terms of an array, what is an index?
he first element in an array
A value which points to a data element in an array
A list of all the elements in an array
In the known abstract data types, which returns an overflow or underflow error?
Linked List
Stacks
Queues
Graphs
Trees
A Binary search requires the data it is searching to be ordered in some way...
True
FALSE
Not all the time
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, the no of element present on stack are
1
2
3
4
5
Does Abstracts Data Types support the programmer's efficiency?.
Yes
No
choose the two types of the Data
Primitive Data Type
return
User defined Data
void
What is an algorithm?
placeholders for representing data
is a sequence of instructions or a set of rules that are followed to complete a task.
Something that comes somewhere in between formatted English and computer program code
The arrangement of and relations between
the parts or elements of something.
Correct code to define a list C++?
Int[] scores = {15, 29, 4, 50};
int scores [4]= {15, 29, 4, 50}
int scores = (15, 29, 4, 50)
none of the above
It use pointer to link nodes.
Variable
Trees
Pointer
Link List
Differentiate priori and posterio analysis in one sentence (5 points)
In doing shell sort algorithm, what will you do after you swapped the values using the Knuth's formula and the interval of 1?
Sort the remaining sub list using bubble sort
Identify the pivot value then implement merge sort
Use insertion sort
all of the above
Why do we use the isFull() function in a queue?
A. to identify if the list has any available position, so we can add if there is or send an overflow error message otherwise
B. to detect the size of the list then resize it when necessary to adjust the size of the queue
both A and B
no answer
What will happen during a dequeue operation and the algorithm found out that the list is already empty?
an underflow error message will appear
an overflow error message will appear
an error message will appear
a queue is full error message will appear
to be able to use interpolation search, we need to get the ______________ from the list
middle position
probing position
interval position
high and low position
When the item being search in binary search does not match to the calculated middle position because the search item is at the upper list, what will you do?
reassign a new value to the lowest position whereas: low = mid + 1
reassign a new value to the highest position whereas: high = mid - 1
reassign a new value to the lowest position whereas: mid = mid + 1
none of the above
It talks about arranging data in a particular format, whether ascending or descending.
Searching
Stacking
Queueing
Sorting
Bonus question: what is the significance of learning Data Structures and understanding the use of algorithm in day to day life as an IT person?
Special Format for storing and organizing data
Algorithm
Algorithm Design
Data Structure
Data Algorithm
A complete binary tree where the value of each of each parent node is either higher or lower than the value of its child nodes.
Tree
Heap
Queue
Linked List
an ordered list in which the first element added is the first element retrieved or removed (First-In, FirstOut).
Heap
Tree
Stack
Queue
an ordered list in which the last element added is the first element retrieved or removed (Last-In, First-Out).
Stack
Queue
Tree
Heap
A series of values stored in memory is called ___
an array
a tree
a matrix
a struct
A flexible data structure that can store many nodes is called ___
a tree
a linked list
a pointer
a queue
When linked lists are used as stacks, what kind of behaviour is implemented?
First-In First-Out, or FIFO
First-In Last-Out, or FILO
Last-In Last-Out, or LILO
Last-In First-Out, or LIFO
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)
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
Consider the following operations performed on a stack of size 5:
Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop();Pop(); Push (e)
Which of the following statements is correct?
Underflow occurs
Stack operations are performed smoothly
Overflow occurs
None of the above
User perform following operations on stack of size 5 then -
push(1);
pop();
push(2);
push(3);
pop();
push(2);
pop();
pop();
push(4);
pop();
pop();
push(5);
Overflow Occurs
Stack Operations will be performed Smoothly
Underflow Occurs
None of these
Consider above is a Stack implemented using the array.
In this implementation of stack maximum value of top which cannot cause overflow will _________.
11
10
9
None of the answer
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)
Pointer is __________ data type
derived
primary
user defined
none of above
Array is ___________ data type.
user defined
primary
derived
all of above
In ____________ data structure, the data items are arranged in a linear sequence.
linear
non linear
both a and b
all of above
In ___________ data structure data items are not in sequence.
non linear
linear
non-homogeneous
all of above
____________data structures are those whose sizes and structures associated memory locations are fixed at compile time.
linear
homogeneous
static
dynamic
What does LIFO stand for?
Last In First Out
Least In Flow Out
Last In Flow Out
Last In First Object
Why do we need to organize data in a computer? Check all possible answers.
You will easily direct someone to access a file for you.
You will easily update back-ups or switch computers.
You will always know where to find what you need.
You will never waste time where to save anything.
_is a way to classify various types of data such as integer, string, etc.
Dynamic programming
Data Type
Data object
Basic Operations
_is used where we have problems, which can be divided into similar sub-problems, so that their results can be re-used. Mostly, these algorithms are used for optimization.
Top-down approach
Bottom-up approach
Data type
Dynamic Programming
which one is the example of built in data type
Deletion
List
Stack
Integers
_similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems.
Fibonacci series
Dynamic programming approach
Algorithm
tabulation
Fibonacci sequence looks like
0,0,1,2,3,5,8,
0,0,1,2,3,5,8,13
0,1,1,1,2,3,5,8,
0,1,1,2,3,5,8,13
a linear data structure, in which the elements are not stored at contiguous memory locations.
arrays
stack
Queue
Linked list
a collection of items stored at contiguous memory locations.
index
Array
stack
queue
a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top
Queue
Stack
Array
Linked List
is a linear structure that follows a particular order in which the operations are performed. The order is First In First Out (FIFO).
Queue
Stack
Array
tabulation
_is a way to classify various types of data such as integer, string, etc.
Dynamic programming
Data Type
Data object
Basic Operations
_is used where we have problems, which can be divided into similar sub-problems, so that their results can be re-used. Mostly, these algorithms are used for optimization.
Top-down approach
Bottom-up approach
Data type
Dynamic Programming
_is a region of storage that contains a value or group of values.
Built-in Data Type
Data Object
Derived Data Type
Basic Operations
which one is the example of built in data type
Deletion
List
Stack
Integers
which one is the example of basic operations
Searching
Array
Character
& Strings
Integers
_similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems.
Fibonacci series
Dynamic programming approach
Algorithm
tabulation
a collection of items stored at contiguous memory locations.
index
Array
stack
queue
a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top
Queue
Stack
Array
Linked List
