Persistent Technical Interview Questions
Persistent Technical Interview Questions and Answers 2024
On this page, you will get the most recently asked technical questions as well as answers in the Persistent Technical Interview 2024.
Page Highlights:
- Persistent Test Pattern
- Top 20 Persistent Technical Interview Questions
Persistent Test Pattern
Persistent Assessment Details | No. of Questions | Time |
---|---|---|
Computer Science | 20 Questions | 20 minutes |
English Comprehension | 12 Questions | 15 minutes |
Logical Ability | 12 Questions | 15 minutes |
Automata | 2 Questions | 45 minutes |
Top 20 Persistent Technical Interview Questions
Question 1: What do you mean by preprocessor directives?
Answer:
Preprocessor directives are generally found on a distinct line at the top of the source code, beginning with the character “#,” followed by the directive name and optional whitespace. Preprocessor directives are used to make altering and compiling source code in multiple execution environments easier.
Question 2:- What is buffer overflow?
Answer:
A buffer overflow happens when a program or process attempts to write more data to a fixed-length block of memory, or buffer, than the buffer, is designed to hold. Buffers are designed to hold a specific quantity of data.
Question 3: What is a “Default Gateway”?
Answer:
The IP address of the router in the network serves as the default gateway. In any case, if the user wishes to connect to another network or if they are unable to discover their specific network, their inquiry will be routed to the default gateway.
Questions 4: How does Java enable high performance?
Answer:
Java utilizes a Just In Time compiler to achieve great performance. The instructions are converted into bytecodes using JIT.
Question 5: What are linear and nonlinear data Structures?
Answer:
- Linear: If the elements of a data structure form a sequence or a linear list, the structure is said to be linear. The array is one example.
- Non-Linear: A data structure is considered to be non-linear if the traversal of nodes is nonlinear. Graphs and trees are two examples.
Question 6: What is DHCP and what it is used for?
Answer:
DHCP is the full form of Dynamic Host Configuration Protocol. It is used to assign IP addresses to several computer systems in a network. It makes it very simple to manage a lot of IPs.
Question 7: What is .net core?
Answer:
The most recent general-purpose programming platform supported by Microsoft is called .NET Core. It works across multiple platforms and has been overhauled to make.NET quick, flexible, and modern. This is actually one of Microsoft’s most significant contributions. Developers may now use.NET to create Open Source applications for Android, iOS, Linux, Mac, and Windows.
Question 8: What do you mean by FIFO?
Answer:
First In First Out is a data structure management method that processes the oldest element first and the newest element last.
Questions 9: What is a subnet?
Answer:
A logical division of an IP network is referred to as a subnetwork or subnet. Subnetting is a computer networking technology that separates a larger network address space into smaller, independent ones.
Question 10: What are arrow functions?
Answer
The arrow function is one of the new features of the JavaScript ES6 version. It enables you to create functions in a cleaner manner than conventional functions.
Question 11: Write a code for Heap sort.
#include // including library files int temp; void heapify(int arr[], int size, int i)//declaring functions { int max = i; int left = 2*i + 1; int right = 2*i + 2;if (left < size && arr[left] >arr[max]) max= left; if (right < size && arr[right] > arr[max]) max= right; if (max!= i) { // performing sorting logic by using temporary variable temp = arr[i]; arr[i]= arr[max]; arr[max] = temp; heapify(arr, size, max); } } void heapSort(int arr[], int size)// providing definition to heap sort { int i; for (i = size / 2 - 1; i >= 0; i--) heapify(arr, size, i); for (i=size-1; i>=0; i--) { // swaping logic temp = arr[0]; arr[0]= arr[i]; arr[i] = temp; heapify(arr, i, 0); } } void main() // defining main() { int arr[] = {58, 134, 3, 67, 32, 89, 15, 10,78, 9}; // array initializing with their elements. int i; int size = sizeof(arr)/sizeof(arr[0]); heapSort(arr, size); printf("printing sorted elements\n"); // printing the sorted array for (i=0; i<size; ++i) printf("%d ",arr[i]); }
#include using namespace std; void heapify(int arr[], int n, int i) { int largest = i; int l = 2*i + 1; int r = 2*i + 2; //If left child is larger than root if (l < n && arr[l] > arr[largest]) largest = l; //If right child largest if (r < n && arr[r] > arr[largest]) largest = r; //If root is nor largest if (largest != i) { swap(arr[i], arr[largest]); //Recursively heapifying the sub-tree heapify(arr, n, largest); } } void heapSort(int arr[], int n) { for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i); //One by one extract an element from heap for (int i=n-1; i>=0; i--) { //Moving current root to end swap(arr[0], arr[i]); //Calling max heapify on the reduced heap heapify(arr, i, 0); } } //Function to print array void display(int arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << "\t"; } cout << "\n"; } int main() { int arr[] = {1, 14, 3, 7, 0}; int n = sizeof(arr)/sizeof(arr[0]); cout << "Unsorted array \n"; display(arr, n); heapSort(arr, n); cout << "Sorted array \n"; display(arr, n); }
// Java program for implementation of Heap Sort public class PrepInsta { //Main() for the execution of the program public static void main(String args[]) { int a[] = {12, 11, 13, 5, 6, 7}; int len = a.length;PrepInsta ob = new PrepInsta(); ob.sort(a); System.out.println("Sorted array is"); printArray(a); } public void sort(int a[]) { int len = a.length; // Build heap (rearrange array) for (int i = len / 2 - 1; i >= 0; i--) heapify(a, len, i); // One by one extract an element from heap for (int i=len-1; i>=0; i--) { // Move current root to end int temp = a[0]; a[0] = a[i]; a[i] = temp; // call max heapify on the reduced heap heapify(a, i, 0); } } // To heapify a subtree rooted with node i which is // an index in arr[]. n is size of heap void heapify(int a[], int len, int i) { int largest = i; // Initialize largest as root int l = 2*i + 1; // left = 2*i + 1 int r = 2*i + 2; // right = 2*i + 2 // If left child is larger than root if (l < len && a[l] > a[largest]) largest = l; // If right child is larger than largest so far if (r < len && a[r] > a[largest]) largest = r; // If largest is not root if (largest != i) { int swap = a[i]; a[i] = a[largest]; a[largest] = swap; // Recursively heapify the affected sub-tree heapify(a, len, largest); } } /* A utility function to print array of size n */ static void printArray(int a[]) { int len = a.length; for (int i=0; i<len; ++i) System.out.print(a[i]+" "); System.out.println(); } }
Question 12: Write a code for printing pyramid star pattern.
num = int(input("Enter the Number: ")) for i in range(0, num): for j in range(0, num-i-1): print(" ", end="") for j in range(0, i*2+1): print("*", end="") print()
Question 13: Write a code for the deletion in AVL Tree using a program using JAVA.
class Node { int key, height; Node left, right; Node(int d) { key = d; height = 1; } } class AVLTree { Node root; int height(Node N) { if (N == null) return 0; return N.height; } Node rotateRight(Node b) { Node a = b.left; Node c = a.right; a.right = b; b.left = c; b.height = Math.max(height(b.left), height(b.right)) + 1; a.height = Math.max(height(a.left), height(a.right)) + 1; return a; } Node rotateLeft(Node a) { Node b = a.right; Node c = b.left; b.left = a; a.right = c; a.height = Math.max(height(a.left), height(a.right)) + 1; b.height = Math.max(height(b.left), height(b.right)) + 1; return b; } int getBalance(Node N) { if (N == null) return 0; return height(N.left) - height(N.right); } Node insert(Node node, int key) { if (node == null) return (new Node(key)); if (key < node.key) node.left = insert(node.left, key); else if (key > node.key) node.right = insert(node.right, key); else return node; node.height = 1 + Math.max(height(node.left), height(node.right)); int balance = getBalance(node); if (balance > 1 && key < node.left.key) return rotateRight(node); if (balance < -1 && key > node.right.key) return rotateLeft(node); if (balance > 1 && key > node.left.key) { node.left = rotateLeft(node.left); return rotateRight(node); } if (balance < -1 && key < node.right.key) { node.right = rotateRight(node.right); return rotateLeft(node); } return node; } Node minValueNode(Node node) { Node temp; for(temp=node;temp.left!=null;temp=temp.left); return temp; } Node deleteNode(Node root, int key) { if (root == null) return root; if (key < root.key) root.left = deleteNode(root.left, key); else if (key > root.key) root.right = deleteNode(root.right, key); else { if ((root.left == null) || (root.right == null)) { Node temp = null; if (temp == root.left) temp = root.right; else temp = root.left; if (temp == null) { temp = root; root = null; } else root = temp; } else { Node temp = minValueNode(root.right); root.key = temp.key; root.right = deleteNode(root.right, temp.key); } } if (root == null) return root; root.height = Math.max(height(root.left), height(root.right)) + 1; int balance = getBalance(root); if (balance > 1 && getBalance(root.left) >= 0) return rotateRight(root); if (balance > 1 && getBalance(root.left) < 0) { root.left = rotateLeft(root.left); return rotateRight(root); } if (balance < -1 && getBalance(root.right) <= 0) return rotateLeft(root); if (balance < -1 && getBalance(root.right) > 0) { root.right = rotateRight(root.right); return rotateLeft(root); } return root; } void preOrder(Node node) { if (node != null) { System.out.print(node.key + " "); preOrder(node.left); preOrder(node.right); } } public static void main(String[] args) { AVLTree tree = new AVLTree(); tree.root = tree.insert(tree.root, 3); tree.root = tree.insert(tree.root, 1); tree.root = tree.insert(tree.root, 5); tree.root = tree.insert(tree.root, 0); tree.root = tree.insert(tree.root, 2); tree.root = tree.insert(tree.root, 4); tree.root = tree.insert(tree.root, 6); System.out.println("Preorder traversal is : "); tree.preOrder(tree.root); tree.root = tree.deleteNode(tree.root, 6); tree.root = tree.deleteNode(tree.root, 5); tree.root = tree.deleteNode(tree.root, 4); System.out.println(""); System.out.println("Preorder traversal after "+"deletion of [6,5,4] :"); tree.preOrder(tree.root); } }
Question 14: Write a program to find the roots of a quadratic equation.
Question 15: Write a C++ program for implementing a queue using two stacks.
#include<bits/stdc++.h> using namespace std; class Queue { public: stack s1,s2; void Push(int i) { cout<<“Pushing the element : “<<i<<endl; s1.push(i); } int pop() { if(s1.empty()) {cout<<“The queue is empty”<<endl;return –1;} while(!s1.empty()) {s2.push(s1.top());s1.pop();} int b=s2.top();s2.pop(); cout<<“Popping the element : “<<b<<endl; while(!s2.empty()) {s1.push(s2.top());s2.pop();} return b; } void Show() { while(!s1.empty()) { s2.push(s1.top());s1.pop(); } while(!s2.empty()) { cout<<s2.top()<<” “; s1.push(s2.top());s2.pop(); } } int front() { if(s1.empty()) {cout<<“The queue is empty”<<endl;return –1;} while(!s1.empty()) {s2.push(s1.top());s1.pop();} int b=s2.top(); while(!s2.empty()) {s1.push(s2.top());s2.pop();} return b; } }; int main() { Queue q; q.Push(1);q.Push(5);q.Push(2);q.Push(11); cout<<“The Queue now is : “; q.Show();cout<<endl; cout<<“The front value right now is : “<<q.front()<<endl; q.pop();q.pop(); q.Push(12);q.Push(8); cout<<“The front value right now is : “<<q.front()<<endl; cout<<“The Queue now is : “; q.Show();cout<<endl; }
Question 16: Write a code to calculate the area of a circle using C and C++.
#includeint main(){ float r =3, pi=3.14, area; area=pi*r*r; printf("Area of circle is %.2f", area); }
#include<bits/stdc++.h> using namespace std; int main(){ float rad = 3, area; area=(3.14*rad*rad); cout<<"Area of circle is "<<area; }
Question 17: Write a program to insert a node in middle of the linked list.
Question 18: Write a program to move all the negative elements to one side of the array.
#includevoid shiftall(int arr[], int left, int right) { while (left<=right) { if (arr[left] < 0 && arr[right] < 0) left+=1; else if (arr[left]>0 && arr[right]<0) { int temp=arr[left]; arr[left]=arr[right]; arr[right]=temp; left+=1; right-=1; } else if (arr[left]>0 && arr[right] >0) right-=1; else{ left += 1; right -= 1; } } } void display(int arr[], int right){ for (int i=0;i<=right;++i){ printf("%d ",arr[i]); } printf("\n"); } int main() { int n; scanf("%d", &n); int arr[n]; for(int i=0; i<n; i++) scanf("%d", &arr[i]); // Function Call shiftall(arr,0,n-1); display(arr,n-1); return 0; }
#include using namespace std; // Function to shift all the // negative elements on left side void shiftall (int arr[], int left, int right) { while (left <= right) { if (arr[left] < 0 && arr[right] < 0) left += 1; else if (arr[left] > 0 && arr[right] < 0) { int temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; left += 1; right -= 1; } else if (arr[left] > 0 && arr[right] > 0) right -= 1; else { left += 1; right -= 1; } } } void display (int arr[], int right) { for (int i = 0; i <= right; ++i) { cout << arr[i] << " "; } cout << endl; } int main () { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; // Function Call shiftall (arr, 0, n - 1); display (arr, n - 1); return 0; }
import java.util.*; public class Main { public static void shift(int[] arr) { int j = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] < 0) { if (i != j) swap(arr, i, j); j++; } } for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " "); } } // used for swapping ith and jth elements of array public static void swap(int[] arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } public static void main(String[] args) throws Exception { int[] arr = new int[]{ -1,0,3,1,-4}; shift(arr); } }
def find(arr): # sort array arr.sort() # print array print("Array after moving all the elements to left:", arr) array = [1, 3, -1, 4, -3, -5, -6, 3, 7] # call function find(array)
Question 19: Write a JAVA program to trap rain water problem
public class Main { public static int maxWater(int[] arr, int n) { // To store the maximum water // that can be stored int res = 0; // For every element of the array // except first and last element for (int i = 1; i < n - 1; i++) { // Find maximum element on its left int left = arr[i]; for (int j = 0; j < i; j++) { left = Math.max(left, arr[j]); } // Find maximum element on its right int right = arr[i]; for (int j = i + 1; j < n; j++) { right = Math.max(right, arr[j]); } // Update maximum water value res += Math.min(left, right) - arr[i]; } return res; } // Driver code public static void main(String[] args) { int[] arr = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; int n = arr.length; System.out.print(maxWater(arr, n)); } }