Practice IT Operating System Questions and Answers
- Consider the following C code: #include #include int main() { Β Β char str1[] = "Hello"; Β Β char str2[] = {'W', 'o', 'r', 'l', 'd', '\0', 'X'}; Β οΏ½...
- Consider the following Java code: import java.util.Arrays; public class Splitter { Β Β public static void main(String[] args) { Β Β Β Β String data =...
- In a Selection Sort algorithm, the inner loop finds the index of the minimum element in the unsorted part. Which line correctly completes the if condition ...
- Complete the while loop condition for an iterative binary search implementation. def binary_search(arr, target): Β Β low = 0 Β Β high = len(arr) - 1 Β ...
- In a Ternary Search algorithm, the array is divided into three parts. Complete the calculation for mid1 and mid2. def ternary_search(arr, target): Β Β lo...
- When building a Huffman tree, the two nodes with the smallest frequencies are combined. Which line correctly creates a new parent node newNode with left an...
- The first step in the greedy Activity Selection problem is to sort the activities. Which criterion is used for sorting to ensure the greedy choice property...
- In the dynamic programming solution for Matrix Chain Multiplication, the outermost loop iterates over the len (chain length). What are the correct loop bou...
- Complete the recurrence relation for dp[i][j] in the Longest Common Subsequence (LCS) problem when text1[i-1] is *not equal* to text2[j-1]. # dp[i][j] stor...
- In a common backtracking approach to generate permutations of a string, elements are swapped to explore different arrangements. Complete the line that swap...
- In a recursive subset_sum function, backtrack(index, current_subset, current_sum), to explore the option of *including* the current element arr[index], whi...
- In the Knuth-Morris-Pratt (KMP) algorithm, the Longest Proper Prefix Suffix (LPS) array lps[] is crucial. When pat[i] and pat[len] match, len is incremente...
- A Python function get_element(arr, index) is supposed to return the element at a given index. def get_element(arr, index): Β Β # Assume arr is a list of ...
- Consider a Java method printList(Node head) for a singly linked list. class Node { Β Β int data; Β Β Node next; Β Β Node(int d) { data = d; next = nu...
- A C function pop(Stack* s) is designed to remove and return the top element from a stack. #include #include #define MAX_SIZE 10 typedef struct { Β Β in...
- A Python Queue class uses a list. Its is_empty method is implemented incorrectly. class Queue: Β Β def __init__(self): Β Β Β Β self._items = [] Β Β ...
- A Java method isLeaf(TreeNode node) is intended to check if a given node is a leaf in a binary tree. class TreeNode { Β Β int val; Β Β TreeNode left, r...
- A C function insert(Node* root, int data) for a BST. #include typedef struct Node { Β Β int data; Β Β struct Node *left, *right; } Node; Node* newNode...
- Java MinHeap class has a heapifyDown method. public class MinHeap { Β Β private ArrayList heap; Β Β public MinHeap() { Β Β Β Β heap = new ArrayList...
- You are using Python's built-in dict to store custom objects. class MyObject: Β Β def __init__(self, value): Β Β Β Β self.value = value Β Β # Missi...
- A C function print_matrix(int rows, int cols, int matrix[rows][cols]) is designed to print a matrix. #include void print_matrix(int rows, int cols, int ma...
- You are trying to parse a JSON string in Java using a library like org.json. import org.json.JSONObject; import org.json.JSONException; public class JsonPa...
- Which OOP principle focuses on showing only essential information and hiding the complex implementation details from the user?
- Consider the following Python code: from abc import ABC, abstractmethod class Shape(ABC): Β Β @abstractmethod Β Β def area(self): Β Β Β Β pass clas...
- The following Java code attempts to define an abstract class and use it. Identify the best way to correct the error to allow instantiation of a concrete cl...
- In C++, how is abstraction primarily achieved when defining a class that cannot be instantiated directly but serves as a blueprint for derived classes?
- Which module in Python is used to define Abstract Base Classes (ABCs)?
- What is the primary difference between an abstract class and an interface in Java regarding abstraction?
- Consider the following C++ code: #include class Base { public: Β Β virtual void show() = 0; }; class Derived : public Base { public: Β Β void show() o...
- The following Python code intends to enforce that all `Worker` subclasses implement a `work` method. However, it's not working as expected. class Worker: οΏ½...
- Which of the following statements about abstract methods in Java is true?
- The following C++ code has a compilation error. How can you correct it to properly use the abstract base class `Printer`? #include class Printer { public:...
- Which of the following data structures follows the Last-In, First-Out (LIFO) principle?
- In a singly linked list, each node typically contains two parts. What are they?
- Which data structure is best suited for implementing a Breadth-First Search (BFS) algorithm?
- What is the primary disadvantage of using an array as a data structure?
- Which of the following is a non-linear data structure?
- What is the time complexity for accessing an element at a specific index in an array?
- Which operation adds an element to the rear of a queue?
- What is the worst-case time complexity of the Bubble Sort algorithm?
More Topics
- Algorithms Questions
- Analog and Digital Communication Questions
- Artificial Intelligence & Machine Language Questions
- Basics of Computers Questions
- Big Data Analytics Questions
- C Programming Questions
- C++ Questions
- Cloud Computing Questions
- Compiler Design Questions
- Computer Architecture and Design Questions
- Cyber Security Questions
- Data Analytics Languages Questions
- Data Structure Questions
- Data Warehousing Questions
- Digital Logic Questions
- Emerging Technologies Questions
- IOT and mobile Computing Questions
- IT DBMS Questions
- IT Networking Questions
- Java Language Questions
- Machine Learning Questions
- Memory Management Questions
- Microsoft Office Questions
- Miscellaneous Questions Questions
- Network Layer and IP Protocol Questions
- Numerical and Statistical Computing Questions
- Object Oriented Programming Questions
- OOPS Concepts Questions
- Previous Year Questions Questions
- Programming Concept Questions
- Python Questions
- Shell Scripting Questions
- Software Engineering and Web Technology Questions
- SQL Questions
- String Manipulation Questions
- TCP IP and OSI Questions