CUET Exam  >  CUET Tests  >  CUET Mock Test Series  >  Computer Science: CUET Mock Test - 10 - CUET MCQ

Computer Science: CUET Mock Test - 10 - CUET MCQ


Test Description

40 Questions MCQ Test CUET Mock Test Series - Computer Science: CUET Mock Test - 10

Computer Science: CUET Mock Test - 10 for CUET 2024 is part of CUET Mock Test Series preparation. The Computer Science: CUET Mock Test - 10 questions and answers have been prepared according to the CUET exam syllabus.The Computer Science: CUET Mock Test - 10 MCQs are made for CUET 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Computer Science: CUET Mock Test - 10 below.
Solutions of Computer Science: CUET Mock Test - 10 questions in English are available as part of our CUET Mock Test Series for CUET & Computer Science: CUET Mock Test - 10 solutions in Hindi for CUET Mock Test Series course. Download more important topics, notes, lectures and mock test series for CUET Exam by signing up for free. Attempt Computer Science: CUET Mock Test - 10 | 40 questions in 45 minutes | Mock test for CUET preparation | Free important questions MCQ to study CUET Mock Test Series for CUET Exam | Download free PDF with solutions
1 Crore+ students have signed up on EduRev. Have you? Download the App
Computer Science: CUET Mock Test - 10 - Question 1

Which of the following is not a keyword in python language?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 1

'val' is not a keyword in python language. All the other options are correct keywords used in python language.

Computer Science: CUET Mock Test - 10 - Question 2

Earlier version of SQL name is:

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 2

SEQUEL later became SQL (still pronounced "sequel"). In 1979, Relational Software, Inc. (now Oracle) introduced the first commercially available implementation of SQL. Today, SQL is accepted as the standard RDBMS language.

Computer Science: CUET Mock Test - 10 - Question 3

Which of the following is the correct way to call a function?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 3

The correct way to call a function is my_func().

Computer Science: CUET Mock Test - 10 - Question 4

What is the syntax to work with the database?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 4

USE DatabaseName;
The database name should always be unique within the RDBMS.

Computer Science: CUET Mock Test - 10 - Question 5

Which of the following components is/are part(s) of a function header in python?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 5

Function Name and Parameter List are parts of a function header in python.

Computer Science: CUET Mock Test - 10 - Question 6

What is the global system of interconnected computer networks called?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 6

Internet is a global system because it interconnects the networks worldwide.

Computer Science: CUET Mock Test - 10 - Question 7

Syntax of the seek function in python is myfile.seek(offset, reference_point) where myfile is the file object. What is the default value of reference_point?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 7

Python file method seek() sets the file's current position at the offset. The whence argument is optional and defaults to 0, which means absolute file positioning; other values are 1, which means seek relative to the current position, and 2, which means seek relative to the file's end. There is no return value.

Computer Science: CUET Mock Test - 10 - Question 8

Read the statements given below and choose the correct answer:

Statement A: It is very difficult to organize unstructured data.
Statement B: CSV helps into organize a huge amount of data in a proper and systematic way.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 8

Unstructured data offers more flexibility and scalability. The absence of the pre-defined purpose of unstructured data makes it super flexible as the information can be stored in various file formats. Yet, this data is subjective and more difficult to work with. CSV helps into organize a huge amount of data in a proper and systematic way.

Computer Science: CUET Mock Test - 10 - Question 9

Two statements are given below:

Statement I: The order of items in the output of the map() method in Python is same as the order in the input iterable.
Statement II: The order of items in the output of the map() method in Python is sorted in ascending order.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 9

The map() method in Python preserves the order of items in the input iterable, and applies the given function to each item in that order. Therefore, the order of items in the output of the map() method is the same as the order in the input iterable. The order of items in the output of the map() method in Python is not sorted in ascending order.

Computer Science: CUET Mock Test - 10 - Question 10

Stack is a ___________ data structure.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 10

Stacks are dynamic data structures that follow the Last In First Out (LIFO) principle. The last item to be inserted into a stack is the first one to be deleted from it.

Computer Science: CUET Mock Test - 10 - Question 11

Directions: Match the contents under List I with those under List II.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 11
  • Border Gateway Protocol (BGP) is a protocol used for exchanging routing information between different autonomous systems on the Internet. Multiprotocol Label Switching (MPLS) is a protocol used for forwarding network packets based on labels. It is used to improve the speed and efficiency of network traffic.
  • Internet Protocol Security (IPsec) is a protocol used for securing Internet Protocol (IP) communications. It provides confidentiality, integrity, and authentication services for IP packets.
  • Dynamic Host Configuration Protocol (DHCP) is a protocol used for assigning IP addresses to devices on a network. It allows devices to automatically obtain IP addresses and other network configuration information.
Computer Science: CUET Mock Test - 10 - Question 12

In a relational schema, each tuple is divided into fields called

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 12

Each tuple is divided into fields called domains in relational schema.

Computer Science: CUET Mock Test - 10 - Question 13

Antivirus software is an example of _____.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 13

Antivirus software is a type of security software designed to protect users from multiple types of malware, not just viruses.

Computer Science: CUET Mock Test - 10 - Question 14

A ________ computer is a large and expensive computer capable of simultaneously processing data for hundreds or thousands of-users.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 14

A mainframe computer is a large and expensive computer capable of simultaneously processing data for hundreds or thousands of users. Mainframe computers (colloquially referred to as "big iron") are computers used primarily by large organizations for critical applications, bulk data processing, such as census, industry and consumer statistics, enterprise resource planning, and transaction processing.

Computer Science: CUET Mock Test - 10 - Question 15

Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the following option can be used to read all the remaining lines?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 15

The myfile.readlines() function is used to read the entire files.
To get all the information in a file, readlines() is used. It returns the entire information in the file. The radlines() function gives all data in the file as a collection of strings. When using the readlines() function, all the data in the file is read and it will not be stopped until the entire file ends.

Computer Science: CUET Mock Test - 10 - Question 16

Match List I and List II.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 16
  • Seek() is a built-in Python method that is used to change the position of the file pointer. It takes two arguments: the offset and the origin. The offset specifies the number of bytes to move, and the origin specifies the reference position from where the offset is to be measured.
  • Tell() is a built-in Python method that is used to get the current position of the file pointer. It returns the current position of the file pointer in bytes.
  • Truncate() is a built-in Python method that is used to resize a file to a specified size. If the specified size is smaller than the original size of the file, the file will be truncated to the specified size. If the specified size is larger than the original size of the file, the file will be extended to the specified size, and the extended portion will be filled with null bytes.
  • Binary mode is a file mode used to open a file in binary format. When a file is opened in binary mode, the data is read or written as a sequence of bytes, and no translation is performed on the data. Binary mode is denoted by "b" in the file mode.
Computer Science: CUET Mock Test - 10 - Question 17

Which of the following items are present in the function header?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 17

Function header consists of function name & parameter list.

Computer Science: CUET Mock Test - 10 - Question 18

Given Tuple: tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90)
What will be the output of print (tup1 [3:7:2])?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 18

The output will be (40,60).
In tuples, indexing starts with 0. Therefore on third index, the element will be 40.
Similarly, the element on the seventh index will be 80, but it will not be included as the end value is not included in slicing.
2 represents the iteration gap or steps. Therefore, only 2nd place numbers from start will be printed between the range 40 and 70, i.e. 40 and 60.

Computer Science: CUET Mock Test - 10 - Question 19

Identify the output of the following Python statements.

x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][2] print(y)

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 19
  • Given is a list inside list (called nested lists), so when we assign values to y we are linking an element to it.
  • So, x[1] will select second nested list because in python, the counting starts from 0,1,2... and so on.
  • So, if you want to show 1st value, you have to write 0.
  • Now, after selecting second nested list, we also have to write [2] after x[2], so this will select the third element of the nested list which is 15.0 and, hence, the answer is 15.0
Computer Science: CUET Mock Test - 10 - Question 20

Which of the following statements is true?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 20

Pickle in Python is primarily used in serializing and deserializing a Python object structure. In other words, it's the process of converting a Python object into a byte stream to store it in a file/database, maintain program state across sessions, or transport data over the network.

Computer Science: CUET Mock Test - 10 - Question 21

Which of the following operation easily performed by using a single stack?

Operation 1: ​Job Scheduling
Operation 2: Reversing the elements

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 21

Concept:
Stack:

 A stack is a linear data structure that operates on the Last In First Out principle (LIFO). This signifies that the last thing added to the stack gets deleted first.

Operation 1: ​Job Scheduling
Job scheduling is can not be performed by using a single stack. In Job scheduling, all process follows the first come first served so this operation have to follow by the queue data structure.
Hence it can not be performed by the stack.

Operation 2: reversing the elements
A stack is first in first out, it has two main operations push and pop. Push inserts data into it and pop retrieves data from it. To reverse an element using stack initially push all elements into the stack using the push() method then, retrieve them back using the pop() all the elements. It prints in reverse the elements.
Hence it can be performed by the stack.

Hence the correct answer is only operation 2.

Computer Science: CUET Mock Test - 10 - Question 22

Consider the following program.

def sample():

    stack = []
    return stack

What does the sample function return?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 22

Concept:
The python program is,
def sample():
    stack = []
    return stack
Explanation:
Here sample function creates the stack and returns the element. It has two operations push and pop elements. Every time we can access the topmost element of the stack. Hence the given function for creating a stack.
Hence the correct answer is Creating a stack.

Computer Science: CUET Mock Test - 10 - Question 23

Consider the following infix expression. what is the prefix expression for a given infix expression?

Infix: ((8+9)*(7-6))

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 23

Concept:
Infix:

An infix expression prints the operand 1, operator, and operand 2 respectively.

Prefix:
A Prefix expression prints the operator operand 1, and operand 2 respectively.
The given data,

Infix: ((8+9)*(7-6))
Here the highest priority is () compared to +, -, and *. and
Operand 1=8 
Operand 2=9
Operator = +
The expression is, (+89 * (7-6))
Operand 1=7
Operand 2=6
Operator = -
The expression is, (+89 * -76 )
Operand 1=+89
Operand 2=-76
Operator = *
The expression is, * + 8 9 - 7 6
Hence the correct answer is * + 8 9 - 7 6.

Computer Science: CUET Mock Test - 10 - Question 24

Which of the following data structure is suitable for checking Valid Parentheses?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 24

Concept:

The Stack data structure is suitable for checking valid parentheses. 

  • All of the parentheses are matched, which means that each starting parenthesis has a matching closing parenthesis.
  • The matching parentheses are in the proper order, with the opening parenthesis preceding the closing parenthesis.

{{}}()[()] ----> The parentheses are valid.

{ ] [ }  -------> The parentheses are invalid.​

Algorithm:

  • Create an empty stack.
  • Push an opening parenthesis on top of the stack.
  • In case of a closing bracket, check if the stack is empty.
  • If not, pop in a closing parenthesis if the top of the stack contains the corresponding opening parenthesis.
  • If the parentheses are valid,​ then the stack will be empty once the input string finishes.

Explanation:
And the remaining queue, tree, and list are not suitable for checking valid parentheses because they have no restriction on incoming and outgoing elements. Hence we can not match.
Hence the correct answer is stack.

Computer Science: CUET Mock Test - 10 - Question 25

Consider the following program. 

Here stack parameter is an empty stack and the item is an element.

def sample(stack, item):
    stack.append(item)

What does the sample function do?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 25

The correct answer is option C.

Concept:
The given python program is,
def sample(stack, item):
    stack.append(item)
Here stack parameter is an empty stack and the item is an element.

Explanation:​
The append() method in python adds a single item to the existing list. It doesn't return a new list of items but will modify the original list by adding the item to the end of the list. After executing the method append on the list the size of the list increases by one.
Hence the given sample program adds the elements to the stack.
Hence the correct answer is adding the elements to the stack.

Computer Science: CUET Mock Test - 10 - Question 26

Consider the following program. Here glass stack is an empty stack.

def check(glassStack):
 if len(glassStack)==0:
      return True
 else:
    return False

What does the check function return? 

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 26

Concept:
The python program is,
def check(glassStack):
 if len(glassStack)==0:
      return True
 else:
    return False
The given data, 
Consider a glassstack as an empty stack.

Explanation:
The if blocks check the length of the stack is equal to zero or not. If there are no elements it returns the true. else it returns the false. A function named check( ) to check whether the stack glassStack is empty or not. Remember trying to remove an element from an empty stack would result in ‘underflow’. This function returns True if the stack is empty, else returns False.

Hence the correct answer is check whether the stack glassStack is empty or not.

Computer Science: CUET Mock Test - 10 - Question 27

Consider the input sequence a, b, c, d.

Minimum number of operations(push or pop) required to get stack permutation for sequence b, d, c, a?

Hint:

A stack permutation is a permutation of items in the supplied input queue that is accomplished by transferring elements from the input queue to the output queue using a stack and the built-in push and pop operations.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 27

Concept:
stack permutation:

A stack permutation is a permutation of items in the supplied input queue that is accomplished by transferring elements from the input queue to the output queue using a stack and the built-in push and pop operations.
input: a, b, c, d
Output: b, d, c, a
push a
push b
pop ----------> pop the topmost element i.e b
push c 
push d
pop -----------> pop the topmost element i.e d
pop ----------> pop the topmost element i.e c
pop ----------> pop the topmost element i.e a
Hence the given sequence is the proper sequence.
The minimum number of operations are 8, these are essential to get a proper sequence.
Hence the correct answer is 8.

Computer Science: CUET Mock Test - 10 - Question 28

Example 1:

Consider array has 4 elements and a searching element 16.

A[4]= {10, 16, 22, 25} 

The number of iterations are required to search an element by using a binary search= T1

Example 2:

Consider array has 4 elements and a searching element 22.

A[4]= {10, 16, 22, 25} 
The number of iterations are required to search an element by using a binary search= T2

Note: Searching is successful.

Which of the following statement are true?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 28

Concept:
Binary Search:

A Binary Search is a sorting method used to find a specific member in a sorted array. Because binary search works only on sorted arrays, an array must be sorted before using binary search on it. As the number of iterations in the binary search reduces, it is a superior searching approach to the liner search technique.

Algorithm:
int binarySearch(int a[], int beg, int end, int K)    
{    
    int mid;    
    if(end >= beg)     
    {   mid = (beg + end)/2;    
        if(a[mid] == K)                 
            return mid+1;    
        else if(a[mid] < K) 
            return binarySearch(a, mid+1, end, K);      
        else   
            return binarySearch(a, beg, mid-1, K);            
    }    
    return -1;     
}   

Example 1:
The given data,
A[4]= {10, 16, 22, 25} 
Searching element= K= 16
beg= 0
end = 3
mid = 3/2 = 1
 if K with A[mid] and search is successful. 
Hence the number iterations are =1.

Example 2:
The given data,
A[4]= {10, 16, 22, 25} 
Searching element= K= 22
beg= 0
end = 3
mid = 3/2 = 1.
Compare 22 with A[1] is not found and K is greater than A[mid]. So  call binarySearch(a, 1+1, 3, 2); 
beg= 2
end = 3
mid = 5/2 = 2.
Compare 22 with A[2] is found.
Hence the number of iterations is = 2
Hence the correct answer is T1 < T2.

Computer Science: CUET Mock Test - 10 - Question 29

Which statement is generally used in the beginning of the function or after a function call to check for valid input?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 29

Concept:
Exception:

An exception is an occurrence that happens during program execution that disturbs the regular flow of the program's instructions. When a Python script finds a condition that it cannot handle, it throws an exception. A Python object that reflects an error is known as an exception.

  • Exception Handlers are programs that are designed to run when a specific exception is thrown.
  • Raising an exception involves stopping the usual flow of program execution and navigating to the exception handler. 
  • Raise and assert statements are used to raise exceptions.
  • Raise is often utilized when an erroneous condition has been recognized or when a condition does not fulfilled. Similar to assert, however, the exception is only triggered if a condition is fulfilled.

​Assert:

  • The assert statement is generally used at the beginning of the function or after a function call to check for valid input.
  • The assert statement accepts an expression as well as an optional message.
  • The assert statement is used to validate the types, values of arguments, and function output.
  • The assert statement is used as a debugging tool since it stops the application when an error occurs.

Syntax:
assert <condition>
assert <condition>,<error message>

Raise:
While they try and except blocks are for handling exceptions, the raise keyword on the contrary is to raise an exception.

Syntax:
raise  {name_of_ the_ exception_class}

Hence the correct answer is assert.

Computer Science: CUET Mock Test - 10 - Question 30

Which of the following is true about binary search?

Statement 1: The pre-condition for the binary search is that the elements must be arranged in sorted order.
Statement 2: Binary search is based on the divide and conquers approach.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 30

Concept:
Binary Search:

A Binary Search is a sorting method used to find a specific member in a sorted array. Because binary search works only on sorted arrays, an array must be sorted before using binary search on it. As the number of iterations in the binary search reduces, it is a superior searching approach to the liner search technique.

Statement 1: The pre-condition for the binary search is that the elements must be arranged in sorted order.
True, The precondition for binary search is that the array should be sorted. If the data is not sorted, we can't apply binary search on that array. 

Statement 2: Binary search is based on the divide and conquers approach.
True, The Binary Search algorithm is a divide and conquer algorithm. 
In binary search, we divide (reduce) the array of numbers (search space), conquer the sub-problems by recursively looking at the center point for our target, and divide till we find our target the base case condition on a sorted array of numbers.

Hence the correct answer is Both statement 1 and statement 2.

Computer Science: CUET Mock Test - 10 - Question 31

Which of the following searching method is useful for unsorted arrays?  
1) Linear Search
2) Binary Search

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 31

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.

Binary Search:
A Binary Search is a sorting method used to find a specific member in a sorted array. Because binary search works only on sorted arrays, an array must be sorted before using binary search on it. As the number of iterations in the binary search reduces, it is a superior searching approach than the liner search technique.

Explanation:
When trying to discover a value in an unsorted array, a linear search is the best we can do. However, if the array is sorted in increasing order by value, we can do far better by using a method called binary search. 

  • Binary Search will not work for unsorted data. Linear search searches the searching element by comparing each element in the list and searching element.
  • If a search is found it prints the index or location else searching is not successful.

Hence the correct answer is Only 1.

Computer Science: CUET Mock Test - 10 - Question 32

Which of the following case a linear search and worst case behaviour?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 32

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.
Algorithm:
linear_search(int a[], int n, int X)

  for (int i = 0; i < n; i++)  
    {  
        if (a[i] == X)  
        return i+1;  
    } 
}

Explanation:
Worst-case:

In the Linear Search Algorithm, the worst-case scenario happens when the item to be found is at the end of the Array or the element is not present in the array. Hence the linear search compares each element till the end. So it takes maximum time behavior in linear search.

Best case:
The best case in the Linear Search Algorithm happens when the item to be found is at the beginning of the Array.

Average case:
In the Linear Search Algorithm, the average scenario happens when the item to be found is somewhere in the center of the Array.

Hence the correct answer is a searching element is not present in the array.

Computer Science: CUET Mock Test - 10 - Question 33

Which of the following statements are true?
Statement 1: Linear search is based on the sequential approach and binary search is based on the divide and conquer approach.
Statement 2: Binary search algorithm takes more than a linear search algorithm.

Note: The array is sorted in order.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 33

Concept:

Statement 1: Linear search is based on the sequential approach and binary search is based on the divide and conquer approach.
True, A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched. 
The Binary Search algorithm is a divide and conquers algorithm. 
In binary search, we divide (reduce) the array of numbers (search space), conquer the sub-problems by recursively looking at the center point for our target, and divide till we find our target the base case condition on a sorted array of numbers.

Statement 2: Binary search algorithm takes more than a linear search algorithm.
False, Linear search accesses data sequentially, whereas binary search accesses data randomly. Linear search has a time complexity of O(n) because it needs to compare all the elements in the array, whereas binary search has a time complexity of O (log n). 
A binary search algorithm takes less than a linear search algorithm when the array is in sorted order. The unsorted order can not find an element in a binary search but the linear search can find the element.

Hence the correct answer is Only statement 1.

Computer Science: CUET Mock Test - 10 - Question 34

Which of the following is true about linear search?

Statement 1: linear search is used for an unsorted and unordered small list of elements.
Statement 2: If the searching element is found in the middle of the array, linear search compares the elements till the end of the array.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 34

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.

Algorithm:
linear_search(int a[], int n, int X)


  for (int i = 0; i < n; i++)  
    {  
        if (a[i] == X)  
        return i+1;  
    } 

}

Statement 1: linear search is used for an unsorted and unordered small list of elements.

True, A linear search, often known as a sequential search, is a method for locating an item in a list. It checks each element of the list one by one until a match is discovered or the entire list is searched. It's for a little or huge list of elements that aren't sorted or arranged.

Statement 2: If the searching element is found in the middle of the array, linear search compares the elements till the end of the array.

False, A linear search, often known as a sequential search, is a way of finding anything in a list. It goes over each element of the list one by one until a match is found, or it searches the full list. After the searching element is found the loop breaks and is not needed to compare all elements in the array.

Hence the correct answer is Only statement 1 is true.

Computer Science: CUET Mock Test - 10 - Question 35

Consider array has n elements and searching element X. What is the minimum and the maximum number of comparisons are required to search a element?

Note: Searching is successful.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 35

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.

Algorithm:
linear_search(int a[], int n, int X)

  for (int i = 0; i < n; i++)  
    {  
        if (a[i] == X)  
        return i+1;  
    } 

}

Explanation:
The given data,
An array has n elements and searching element X.
The minimum number of comparisons:
Consider an array is a[5] ={ 12, 5, 48, 79, 11}
X=12
The X element is compared with a[0] and returns the search is successful.
So the minimum number of comparisons is= 1.
The maximum number of comparisons:
Consider an array is a[5] ={ 12, 5, 48, 79, 11}
X=11
The X element is compared with a[0] and not found,and it compares each index element of array i.e a[1], a[2], a[3], a[4].
Then the X element is found at a[4] and returns the search is successful.
So the minimum number of comparisons is= n.
Hence the correct answer is 1,n.

Computer Science: CUET Mock Test - 10 - Question 36

Consider array has n elements and searching element X. What is the minimum and the maximum number of iterations are required to search an element by using binary search?

Note: Searching is successful.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 36

Concept:
Binary Search:

A Binary Search is a sorting method used to find a specific member in a sorted array. Because binary search works only on sorted arrays, an array must be sorted before using binary search on it. As the number of iterations in the binary search reduces, it is a superior searching approach to the liner search technique.

Algorithm:
int binarySearch(int a[], int beg, int end, int K)    
{    
    int mid;    
    if(end >= beg)     
    {   mid = (beg + end)/2;    
        if(a[mid] == K)                 
            return mid+1;    
        else if(a[mid] < K) 
            return binarySearch(a, mid+1, end, K);      
        else   
            return binarySearch(a, beg, mid-1, K);            
    }    
    return -1;     
}   

Minimum number of iterations:
The given data,
A[4]= {10, 16, 22, 25} 
Searching element= K= 16
beg= 0
end = 3
mid = 3/2 = 1
 if K with A[mid] and search is successful. 
Hence minimum number iterations are =1.
Maximum number of iterations:
The given data,
A[4]= {10, 16, 22, 25} 
Searching element= K= 22
beg= 0
end = 3
mid = 3/2 = 1.
Compare 22 with A[1] is not found and K is greater than A[mid]. So  call binarySearch(a, 1+1, 3, 2); 
beg= 2
end = 3
mid = 5/2 = 2.
Compare 22 with A[2] is found.

Explanation:
For in each step the array is being cut into two parts, each of the size (n-1)/2, we have a maximum of log2(n-1) steps. This leads to a total of 2*log2(n-1) comparisons, which asymptotically indeed equals O(log(n)).

Hence the correct answer is 1, log n.

Computer Science: CUET Mock Test - 10 - Question 37

Consider the following array a[ ] with n elements and searching element 16 and the linear search is comparing the elements from index n-1.

a[6]= {15, 87, 20, 16, 9, 11} Here n=6

How many comparisons are required to search a searching element 16 by using linear search?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 37

The correct answer is option C.

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.
Algorithm:
linear_search(int a[], int n, int X)


  for (int i = n-1; i=>0; i++)  
    {  
        if (a[i] == X)  
        return i+1;  
    } 

}

Explanation:
The given data is,
a[6]= {15, 87, 20, 16, 9, 11} Here n=6
X=16
The linear search is comparing the elements from index n-1.
Comparison 1= (11 == 16)
Comparison 2= (9 == 16)Comparison 3= (16 == 16)
Hence the search is successful. Hence the number of comparisons are= 3.
Hence the correct answer is 3.

Computer Science: CUET Mock Test - 10 - Question 38

Which of the following behaviour takes smallest time in linear serach ?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 38

The correct answer is option A.

Concept:
Linear search:

A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.

Algorithm:
linear_search(int a[], int n, int X)

  for (int i = 0; i < n; i++)  
    {  
        if (a[i] == X)  
        return i+1;  
    } 

}

Explanation:

Best case:
The best case in the Linear Search Algorithm happens when the item to be found is at the beginning of the Array. If the element is found at starting of the array the linear search successful and comes out from the loop. Hence this behavior takes less time when compared to other behaviors.

Worst-case:
In the Linear Search Algorithm, the worst-case scenario happens when the item to be found is at the end of the Array or the element is not present in the array. Hence the linear search compares each element till the end. So it takes maximum time behavior in linear search.

Average case:
In the Linear Search Algorithm, the average scenario happens when the item to be found is somewhere in the center of the Array.
Hence the correct answer is a searching element is at beginning of the array.

Computer Science: CUET Mock Test - 10 - Question 39

Consider the array L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]. Suppose you’re searching for the value 3 using binary search method. What is the value of the variable mid after two iterations?

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 39

The starting values of first and last are 0 and 14 respectively.
The iterations are shown below:

Therefore, the value of the variable mid is 3 after the first two iterations.

Computer Science: CUET Mock Test - 10 - Question 40

Identify the improper stack permutation for the input sequence a, b, c, d?

Hint:

A stack permutation is a permutation of items in the supplied input queue that is accomplished by transferring elements from the input queue to the output queue using a stack and the built-in push and pop operations.

Detailed Solution for Computer Science: CUET Mock Test - 10 - Question 40

Concept:
stack permutation:

A stack permutation is a permutation of items in the supplied input queue that is accomplished by transferring elements from the input queue to the output queue using a stack and the built-in push and pop operations.
Option 1: c, d, b, a 
Input: a, b, c, d
Output: c, d, b, a 
push a
push b
push c 
pop -----------> pop the topmost element i.e c
push  d
pop ----------> pop the topmost element i.e d
pop ----------> pop the topmost element i.e b
pop ----------> pop the topmost element i.e a
Hence the given sequence is the proper sequence.
Option 2: d, c, a, b
Input: a, b, c, d
Output: d, c, a, b
push a
push b
push c 
push d
pop -----------> pop the topmost element i.e d
pop ----------> pop the topmost element i.e c
pop ----------> pop the topmost element i.e b
Hence the given sequence is not proper. We can not get element a before b.
Option 3:b, d, c, a
input: a, b, c, d
Output: b, d, c, a
push a
push b
pop ----------> pop the topmost element i.e b
push c 
push d
pop -----------> pop the topmost element i.e d
pop ----------> pop the topmost element i.e c
pop ----------> pop the topmost element i.e a
Hence the given sequence is the proper sequence.
Option 4:a, d, c, b
input: a, b, c, d
Output: a, d, c, b
push a
pop ----------> pop the topmost element i.e a
push b
push c 
push d
pop -----------> pop the topmost element i.e d
pop ----------> pop the topmost element i.e c
pop ----------> pop the topmost element i.e b
Hence the given sequence is the proper sequence.
Hence the correct answer is d, c, a, b.

8 docs|148 tests
Information about Computer Science: CUET Mock Test - 10 Page
In this test you can find the Exam questions for Computer Science: CUET Mock Test - 10 solved & explained in the simplest way possible. Besides giving Questions and answers for Computer Science: CUET Mock Test - 10, EduRev gives you an ample number of Online tests for practice
Download as PDF
Download the FREE EduRev App
Track your progress, build streaks, highlight & save important lessons and more!