HCL Technical Interview Questions

HCL Technical Interview Questions

HCL Technical Interview Questions


1) Does every class have a Constructor?

Yes, every class needs a Constructor. It may be Parameterized or Default. If the user does not define a constructor within a class, the default constructor is always included in that code.

The objective of Constructor is to initialize an object called object initialization. Constructors are mainly created for initializing an object.


2) How Java enable High Performance?

Java uses a Just-In-Time Compiler to enable high performance. Just-In-Time Compiler is a program that turns Java bytecode, which is a program that contains an instruction that must be interpreted into instruction that can be sent directly to the processor.


3) Why is java considered as dynamic?

It is designed to change the evolving environment. Java can carry an extensive amount of runtime information that can be used to verify and resolve access to the object at runtime.


4) What is joins in SQL?

Joins is nothing but connecting two or more table to fetch the record from two or more databases.


5) Can we have Private Constructor in Java?

Private Constructor is used if you do not want other class to instantiate the object. Private Constructor is used in Singleton design Pattern, Factory Method Design Pattern.


6) Differentiate Between Primary Key and Unique Key.

Primary Key Unique Key
1. In a Primary key, there should be only one primary key in a table. 1. In A Unique key, there can be more than one unique key in a table.
2. Primary key will block duplicate value and a null value. 2. Unique key will block duplicate value and accept a null value.

7) Differentiate between Method Overloading and Method Overriding.

Method Overloading Method Overriding
1. Method Overloading is used to gain the readability of the program. 1. Method Overriding is used to provide the specific implementation of the method that already provided by the superclass.
2. In the case of Method Overloading, the parameter must be different. 2. In the case of Method Overriding, the parameter must be equal.
3. Overloading happens at Compile time. 3. Overriding happens at runtime.
4. The Return type of method does not matter in case of method overloading it can be the same or different. 4. In the case of method Overriding, the return type must be the same.
5. you can overload a static, final and private method in Java 5. You cannot override a static, final and private method in Java.

8) What is the purpose of finalize () method in Java?

Finalize () method in java is a special method much like the main method in java. Finalize () method is called before garbage collector reclaims the object, its last chance for any object to perform clean up activity i.e. releasing any fixed order resources held, terminating connection if open etc.


9) Why can static method not override?

A static method cannot override because the static method is bound with class whereas instance method is bound with an object. Static method belongs to the class area and Instance method belong to the heap area.


10) What is singleton Class?

Singleton Class limited the number to one but allowing the flexibility to create more object if the situation changes.


11) Can we override java main method?

No, because main is a Static Method.


12) What is Class Cast Exception?

Class Cast Exception is thrown by java when you try to cast an object of one data type to another data type. Java allows us to cast the variable of one type to another as long as the casting happens between compatible data type.


13) Why polymorphism is used in Java?

The good reason for why polymorphism is a need in Java because the concept is extensively used in implementing inheritance. It plays an important role in allowing the object having a different internal structure to share the same external interface.


14) What is an Abstract class?

An Abstract class is one that is not used to create an object. It is only used as base class for the other class. The Abstract class is always public or friendly.

Syntax:

  1. public abstract class class_name
  2.         {
  3.             //class member
  4.         }

15) Can I have Private Constructor in Abstract Class?

Abstract Class can have Private Constructor But that class cannot be extended by another class. Alternatively, of adding a static inner class inside the Abstract Class and extends that Abstract Class.

Get Free Job Alerts on eMail !

Follow us on Telegram !

Campus Placement Guaranteed !

Follow us on Instagram !

Follow us on Facebook !

Follow us on LinkedIn !

Download Our APP !

Cognizant Technical Interview & Programming Questions

Cognizant Technical Interview & Programming Questions

Cognizant Technical Interview Questions


Questions mainly asked from:

  • C Theory/Programs
  • C++ or Java
  • OOPS
  • Software Engineering
  • Optional – DBMS, Operating Systems, Data Structures

Cognizant C Programming Interview Questions

1) What is a pointer? Define it.

Pointer is a variable which stores the address of other variables which hold some value in it. Directly pointer is used to point values of variables indirectly. We can manipulate its values.


2) What is a dangling pointer in C?

Dangling pointer is a pointer which does not point to a valid object of the appropriate type. It appears when a pointer is in the stack but not in the memory in a heap. Char *p =NULL; A dangling pointer attempt to deallocate without allocating space will result in a segmentation fault.

Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without changing the data of the pointer, so that the pointer points to the memory location of the deallocated memory.


3) What is a memory leak in a heap?

When there is a space area in a heap, but no variable is in the stack pointing to that memory.


4) What is a data type?

Data Type defines the type of value which are allocated by us to a variable and have a range in between we assign values. E.g., “Int” it is a data type which able to store data between “-32768 to +32768” in C.


5) What is the size of the integer data type?

Size of it is 2 Byte or 4 Byte.


6) What is malloc?

Allocates requested size of bytes and returned a pointer first byte of allocated space. Malloc is using for dynamic memory allocation.

Syntax:

  1. ptr = (cast-type*) malloc(byte-size)

7) What is a string?

A string is a sequence of characters. It can be defined using the array or by using String header file.


8) “/0” in a string?

This symbol shows the ending of the string.

E.g. char a[] = {“s”,”e”,”t”,”/0″};.


9) What is recursion?

The process by which a method calls itself directly or indirectly, again and again, is called recursion and the corresponding function.


10) What is the difference between a pre-increment operator and post-increment operator?

Pre-increment operator used incrementing the variable value by one before assigning the cost to the variable. Post-increment operator use to incrementing the variable value by one after assigning the value to the variable.


11) What are the key features or characteristics OFC language?

  • Reliability
  • Portability
  • Flexibility
  • Interactivity
  • Modularity
  • Efficiency and Effectiveness

12) What is embedded C?

Embedded C is the extension of C programming language.

Embedded C is used to develop microcontroller-based applications.

Embedded C includes features not available in standard C like fixed-point arithmetic, named address spaces, and necessary I/O hardware addressing.

Cell phones, MP3 players are some example of embedded systems in which integrated C is used to program and control these devices.


13) Which level is C language belonging?

C language is belonging to middle-level language. C language behaves as a bridge between machine level (low level) languages and high-level languages.

C language is more user-friendly than machine level languages. And, C language does not support all the concepts that high-level languages offer. So, C programming language called as middle-level language.


14) What is the difference between structured oriented, object-oriented and non-structure oriented programming language?

Structured oriented programming language –

In this type of language, large codes fragmented into small programs called functions.
The main focus is on procedures and functions that operate on values
Data moves without any restrictions around the systems from one procedure to another
Program structure follows “Top-Down Approach.”
Example: C, Pascal, ALGOL, and Modula-2

Object-oriented programming language –

In this type of language, programs fragmented into objects
The main focus is on the data/values that are manipulating and not on the procedures or functions.
Data is hidden from functions and cannot access by external functions
Program structure follows the “Bottom UP Approach.”
Example: C++, and C# (C sharp)

Non-structure oriented programming language –

There is no specific structure rule for programming this language.
Example: BASIC, COBOL, FORTRAN


14) What is modifier in C?

Modifiers derive the space to allocate for a variable.

Modifiers are fixed with basic data types to modify (either increase or decrease) the amount of storage allocated to a variable.

For example, storage requirements for int data type are 4 bytes for a 32-bit processor. We can increase range by using long int data type which is 8 byte. We can decrease the range by using short int which is 2 byte.


15) What is the difference between variable declaration and variable definition in C?

Variable declaration tells the compiler about data type and size of the variable. Whereas, variable definition allocates memory to the variable

Variable can be declared many times in a program. But, the definition can happen only one time for a variable in a program.

Variable declaration is for assignment of properties and identification to a variable. Whereas, a variable definition is for assignments of storage space to a variable


Cognizant OOPs Interview Questions


1) What are virtual Functions?

In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overrideable function or method for which dynamic dispatch facilitated. This concept is an essential part of the (runtime) polymorphism portion of object-oriented programming (OOP).


2) What is overloading in OOPs?

Overloading is a process used to avoid redundant code where the same method name used multiple times but with a different set of parameters. The actual method that gets called during runtime is resolved at compile time, thus avoiding runtime errors.


3) What is overriding?

In any object-oriented programming, Overriding is a process that allows a child class or subclass to provide a specific implementation of functions that is already provided by one of its super-classes or parent classes.


4) What is polymorphism?

By using the ability of polymorphism an object can take on multiple types. The frequent use of polymorphism occurs when a parent class refers to an object of the child class. The Java object that can pass more than one IS-A test is polymorphic.


5) What is data abstraction?

In oops, abstraction is one of three main principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object to reduce complexity and increase efficiency.


6) What is encapsulation?

Encapsulation is one of the primary concepts in object-oriented programming. It describes the idea of combining data in a single class and methods that work on that data, e.g., a class which is a blueprint in java. This concept is also often used to preserve the internal state, of an object from the outside.


7) What is Inheritance in java?

In object-oriented programming, inheritance helps new objects to take on the properties of old objects. A class that uses for inheritance is called a base class or superclass. A class that inherits data from a base class is called a subclass or derived class


8) What is the constructor?

A constructor is a method which is used to initialize a newly created object and is called just after when memory allocated to the object. It can be used to implement the objects to desired values or default values at the time of object creation.


9) What is the destructor?

A destructor used when the initialized object is destructing it called automatically during the destruction of an object. It helps in recovering the heap space and remove files.


Cognizant Data structure Interview Questions


1) What is a Data Structure?

Data Structure is a process in which management or organization of data that enable a more efficient way to organize the data.


2) What have linked lists?

A linked list is a set of ordered data and each of its previous nodes connected to its succeeding node. It is like an array but more efficient then array because we can insert or delete data in between the nodes.


3) Is the array of data structure?

Yes, because it also handles the data in a structured way.


4) Define a binary search Tree?

It is also known as ordered or sorted binary tree. It keeps there nodes or keys in sort form, and the root node of BST is bigger than the left node and smaller than the right node.


5) What is a Binary Tree in the data structure?

A binary tree is part of a data structure that has two sub-nodes, a right node, and a left node. In programming, binary trees are an advanced version of the linked list.


6) What is the dissimilarity between Push and Pop methods of the stack?

Pushing and popping applies to the way data is stored and fetched from a stack. A push method denotes data being added to it, meaning information is being “pushed” in the stack. On the other hand, a pop method denotes data retrieval/fetch, and in particular, refers to the first data is being fetched.


7) What is the dissimilarity between a stack and the array?

A stack base on LIFO pattern. It means that data access follows a sequential process wherein the last data to be entered when the first one deleted. Arrays do not follow a particular order and instead can access by referring to the indexed element within the array.


8) What are doubly linked Lists?

Doubly linked lists are a particular part of linked list wherein traversal across the data elements can be done in any directions. This is possible by having two links in every node, one that connects to the next node and another one that links to the previous node.


9) What is a queue data structure?

A Queue is a data structure which is linear and follows a fixed order in which the operations occur. The order is always First In First Out (FIFO). An excellent example of a queue is any queue of the customer for a resource where the customer that came first served first. The difference between stacks and queues is while deleting.


10) What is a stack data structure?

Basic features of Stack are an ordered list of the similar data type. The stack is LIFO (Last In First Out) data structure, or we can say FILO (First In Last Out) data structure. Push () method is used to insert/enter new elements into the Stack and pop() method is used to remove/delete an element from the stack.


11) What is a graph in the data structure?

A graph shows a representation of a set of objects/nodes where some pairs of object/nodes are connected by links/connection. The interconnection of objects are represented by points termed as vertices, and the links that connect the vertices are called edges.


12) What is a priority queue?

A priority queue is an abstracted data type which is like a queue or stack data structure, but where additionally each element has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority.


13) Show the time complexity of the linked list during insertion?

The time complexity of insertion/deletion in a singly linked list depends upon the position where you want to perform them. For example, if you want to insert an element at the end of the linked list, then you have to traverse/travel the entire list, and hence the complexity will be O(n).


Cognizant Programming Questions


1) Write a program to reverse any number.

This code below is written in Java.

  1. package javaapplication6;
  2. import java.util.Scanner;
  3. public class JavaApplication6 {
  4.     public static void main(String[] args)
  5.     {
  6.         int i, temp, sum=0, n;
  7.         Scanner sc = new Scanner(System.in);
  8.         n=sc.nextInt();
  9.         temp=n;
  10.         while(n>0)
  11.         {
  12.             int r = n%10;
  13.             sum = sum*10+r;
  14.             n = n/10;
  15.         }
  16.         System.out.println(“Reverse of Number is:-“ +sum);
  17.         if(temp==sum)
  18.         {
  19.             System.out.println(“Palindrom”);
  20.         }
  21.         else
  22.         {
  23.             System.out.println(“Not Palindrom”);
  24.         }
  25.     }
  26. }

2) Write a program to find out some of the digits of the given number.

  1. package javaapplication6;
  2. import java.util.Scanner;
  3. public class JavaApplication6 {
  4.     public static void main(String[] args)
  5.     {
  6.         int i, temp, sum=0, n;
  7.         Scanner sc = new Scanner(System.in);
  8.         n=sc.nextInt();
  9.         temp=n;
  10.         while(n>0)
  11.         {
  12.             int r = n%10;
  13.             sum = sum+r;
  14.             n = n/10;
  15.         }
  16.         System.out.println(“Reverse of Number is:-“ +sum);
  17.     }
  18. }

3) Write a program to find out the power of a number.

  1. package javaapplication6;
  2. import java.util.Scanner;
  3. public class JavaApplication6 {
  4. public static void main(String[] args)
  5.     {
  6.         int result=1, n;
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.println(“the Exoponent is:- “);
  9.         n=sc.nextInt();
  10.         System.out.println(“the base is:- “);
  11.         int base = sc.nextInt();
  12.         while (n != 0)
  13.     {
  14.         result *= base;
  15.         –n;
  16.     }
  17.         System.out.println(“Power of Number is:-“ +result);
  18.     }
  19. }

4) Write a program to add two numbers without using the addition operator.

  1. package javaapplication6;
  2. import java.util.Scanner;
  3. public class JavaApplication6 {
  4.    static int Add(int x, int y)
  5.     {
  6.         while (y != 0)
  7.         {
  8.             int carry = x & y;
  9.             x = x ^ y;
  10.             y = carry << 1;
  11.         }
  12.         return x;
  13.     }
  14.     public static void main(String arg[])
  15.     {
  16.         Scanner sc = new Scanner(System.in);
  17.         System.out.println(“First value is:- “);
  18.         int a=sc.nextInt();
  19.         System.out.println(“Second value is:- “);
  20.         int b=sc.nextInt();
  21.         System.out.println(“Sum of both digits:- “+Add(a, b));
  22.     }
  23. }

5) Write a program to subtract two numbers without using a subtraction operator.

  1. package javaapplication6;
  2. import java.util.Scanner;
  3.      public class JavaApplication6 {
  4.    static int Add(int x, int y)
  5.     {
  6.         while (y != 0)
  7.         {
  8.             int borrow = ~ x & y;
  9.             x = x ^ y;
  10.             y = borrow << 1;
  11.         }
  12.         return x;
  13.     }
  14.     public static void main(String arg[])
  15.     {
  16.         Scanner sc = new Scanner(System.in);
  17.         System.out.println(“First value is:- “);
  18.         int a=sc.nextInt();
  19.         System.out.println(“Second value is:- “);
  20.         int b=sc.nextInt();
  21.         System.out.println(“Sum of both digits:- “+Add(a, b));
  22.     }
  23.     }

6) Write a program to show largest among three numbers using binary minus operator.

  1. package javaapplication9;
  2. import java.util.Scanner;
  3. public class JavaApplication9 {
  4.     public static void main(String[] args)
  5.     {
  6.         Scanner s = new Scanner(System.in);
  7.         int a = s.nextInt();
  8.         int b = s.nextInt();
  9.         int c = s.nextInt();
  10.         if(a-b>0 && a-c>0)
  11.             System.out.println(“Greatest is a :-“+a);
  12.     else
  13.          if(b-c>0)
  14.              System.out.println(“\nGreatest is b :-“+b);
  15.          else
  16.              System.out.println(“\nGreatest is b :-“+c);
  17.     }
  18. }

7) Write a program to show the largest among three numbers using conditional operator.

  1. package javaapplication9;
  2. import java.util.Scanner;
  3. public class JavaApplication9 {
  4.     public static void main(String[] args)
  5.     {
  6.         Scanner s = new Scanner(System.in);
  7.         int a = s.nextInt();
  8.         int b = s.nextInt();
  9.         int c = s.nextInt();
  10.         int big = a > b ? (a > c ? a : c) : (b > c ? b : c) ;
  11.              System.out.println(“\nGreatest elements is :-“+ big);}}

8) Write a program to show the generic root of any number.

  1. package javaapplication9;
  2. import java.util.Scanner;
  3. public class JavaApplication9 {
  4.     public static void main(String[] args)
  5.     {
  6.         Scanner s = new Scanner(System.in);
  7.         int a = s.nextInt();
  8.         int b=0,c;
  9.         while(a>10){
  10.         b=0;
  11.         while(a>0){
  12.         c=a%10;
  13.         a=a/10;
  14.         b+=c;
  15.         }
  16.         if(b>10)
  17.         a=b;
  18.         else
  19.         break;
  20.     }
  21. System.out.println(“\nSum of the digits in single digit is:-“+b);}}

9) Write a c program to show the prime factor of a given number.

  1. package javaapplication9;
  2. import java.util.Scanner;
  3. public class JavaApplication9 {
  4.     public static void main(String[] args)
  5.     {
  6.         Scanner s = new Scanner(System.in);
  7.         int a = s.nextInt();
  8.         int b=0,c,j,i,isPrime;
  9.        for(i=2; i<=a; i++)
  10.     {
  11.         /* Check ‘i’ for factor of num */
  12.         if(a%i==0)
  13.         {
  14.             /* Check ‘i’ for Prime */
  15.             isPrime = 1;
  16.             for(j=2; j<=i/2; j++)
  17.             {
  18.                 if(i%j==0)
  19.                 {
  20.                     isPrime = 0;
  21.                     break;
  22.                 }
  23.             }
  24.             /* If ‘i’ is Prime number and factor of num */
  25.             if(isPrime==1)
  26.             {
  27.                 System.out.println(i);
  28.             }
  29.         }
  30.     }
  31. }
  32. }

Get Free Job Alerts on eMail !

Follow us on Telegram !

Campus Placement Guaranteed !

Follow us on Instagram !

Follow us on Facebook !

Follow us on LinkedIn !

Download Our APP !

Interview Questions for Electronics / Electrical Core Companies

Interview Questions for Electronics / Electrical Core Companies

Practice Online Aptitude Tests !

Get Free Job Alerts on eMail !

Follow us on Telegram !

Campus Placement Guaranteed !

Follow us on Instagram !

Follow us on Facebook !

Follow us on LinkedIn !

Download Our APP !

Accenture First & Second Round: Technical Interview Questions

Accenture First & Second Round: Technical Interview Questions

Practice Online Aptitude Tests !

Get Free Job Alerts on eMail !

Follow us on Telegram !

Campus Placement Guaranteed !

Follow us on Instagram !

Follow us on Facebook !

Follow us on LinkedIn !

Download Our APP !

60 Wipro important Technical Interview Questions with Answers

60 Wipro important Technical Interview Questions with Answers

Practice Online Aptitude Tests !

Get Free Job Alerts on eMail !

Follow us on Telegram !

Campus Placement Guaranteed !

Follow us on Instagram !

Follow us on Facebook !

Follow us on LinkedIn !

Download Our APP !

Data Structure Interview Questions And Answers For Freshers

Data Structure Interview Questions And Answers For Freshers

Top 50+ Data Structure interview question and answers that are asked for freshers in the technical interview. These are the  top 50+ data structure questions along with efficient answers that you can remember easily.

Join Our Official Telegram Channel For Daily Updates

1. What is data structure? 

Data structure as a methodology that defines, stores, and retrieves data systematically and structurally. Data structure is the process of organizing, storing data in computer that can be used efficiently.

2. Define Linkedlist

A linked list is a sequence of nodes in which each node is connected to the node following it. This forms a chain-like link for data storage.

3. List the areas where data structures are applied?

Data structures are essential in almost every aspect where data is involved. In general, algorithms that involve efficient data structure are applied in the following areas: numerical analysis, operating system, A.I., compiler design, database management, graphics, and statistical analysis, to name a few.

4. Explain  the primary advantage of a linked list?

A linked list is an ideal data structure because it can be modified easily. This means that editing a linked list works regardless of how many elements are in the list.

5. Distinguish  linear from a nonlinear data structure.

Linear data structure:

1.The linear data structure is a structure wherein data elements are adjacent to each other.

2. Examples of linear data structure include arrays, linked lists, stacks, and queues.

Nonlinear data structure:

1. A non-linear data structure is a structure wherein each data element can connect to more than two adjacent data elements.

2.Examples of nonlinear data structure include trees and graphs.

6. What is an Algorithm?

Algorithm denote a sequence of steps to solve a particular problem.

7. Define  graph?

A graph is one type of data structure that contains a set of ordered pairs. These ordered pairs are also referred to as edges or arcs and are used to connect nodes where data can be stored and retrieved.

8. Explain Criteria for  algorithm analysis

Algorithms are analysed based on two factors – space and time. It implies execution time and extra space required on the part of an algorithm.

9. Explain  algorithm’s asymptotic analysis?

For any algorithm, there are three different levels of execution time based on mathematical binding:

  • Representation of the Best Case is done by the symbol Ω(n)
  • Representation of the Worst-Case is done by the symbol Ο(n)
  • Representation of the Average Case is done by the symbol Θ(n)

10. Can we apply the Binary search algorithm to a sorted Linked list?

No, we cannot apply the binary search algorithm to a sorted linked list because finding the index of the middle element is difficult.

Join Our Official You tube channel for Updates & Learning Videos

11. List some  important applications of a Stack?

  • Balanced parenthesis checker
  • Redundant braces
  • Infix to postfix using a stack
  • Infix to prefix using a stack

12. List the common operations performed on a data structure?

  • Insertion – Addition of a data item
  • Deletion – Data item elimination
  • Traversal – Accessing and printing data items
  • Search – Find a data item
  • Sort – Data items arranged in a predefined sequence

13. Differentiate STACK from ARRAY.

Stack follows a LIFO pattern. It means that data access follows a sequence wherein the last data to be stored when the first one to be extracted.

Arrays, on the other hand, do not follow a particular order and instead can be accessed by referring to the indexed element within the array.

14. Are linked lists Linear or Non-linear Data Structures?

Linked lists are considered to be the best of both worlds here. Based on usage, if it is a storage policy, then it can be considered as non-linear. Whereas, if a person is considering it based on retrieval strategies, then it can be considered linear.

15. What are the different approaches to developing algorithms?

There are three commonly used approaches to developing algorithms, which are:

Greedy Approach: Choosing the next best option for finding a solution.

Divide and Conquer: The problem is divided into a minimum possible subproblems and each subproblem is solved independently.

Dynamic Programming: A problem is divided into minimal subproblems, and they are solved together.

16. Explain the use of  stacks?

Stacks uses the LIFO method of addition and retrieval of data items that consume only O(n) time.

If you ever need to access data items in reverse order of their arrival, then you can use stacks.

Stacks are more commonly used in expression parsing, a recursive function call, and depth-first traversal of graphs.

Common operations that you can perform on a stack:

  • push(): Adding an item to the stack top
  • pop(): Removing an item from the stack top
  • peek(): Shows the value of a top item without deleting it
  • is empty(): Check if you have  an empty stack
  • is full(): Checks if you have a full-stack

17. What is the difference between void and null in Data Structures?

Void is a data type identifier in data structures, while null is considered to be a value with no physical presence. When void is used, it indicates that there is no size while initializing the data structure.

18. What is the use of queues?

As the queue follows the First In First Out method, this data structure can be used for working on data items in the exact sequence of their arrival. Queues are widely used in operating systems for different processes. Breadth-First Traversal of Graphs and  Priority Queues are some examples of queues.

19. Mention the  parts of a linked list?

A linked list typically has two parts: the head and the tail.

Between the head and tail lie the actual nodes. All these nodes are linked sequentially.

20. What is merge sort?

Merge sort is a method of sorting, which is based on the divide and conquer technique. Here, data entities adjacent to each other are first merged and sorted in every iteration to create sorted lists. These smaller sorted lists are combined at the end to form the completely sorted list.

Follow us on Instagram for all updates & job notifications

21. What are the minimum nodes binary trees can have?

Binary trees can have zero nodes or a minimum of 1 or 2 as well. It can be zero in a case where all of the nodes have a NULL value.

22. List the Operations that can be performed in a queue:

  • enqueue(): Adding items to the rear end of the queue
  • dequeue(): Removes an item from the front end of the queue
  • peek (): Shows the value of the front item without removing it
  • is empty(): Checks if the stack is empty
  • is full(): Checks if the stack is full

23. What are doubly linked lists?

Doubly linked lists are a special type of linked list wherein traversal across the data elements can be done in both directions. This is made possible by having two links in every node, one that links to the next node and another one that connects to the previous node.

24. Which data structures are used for BFS and DFS of a graph?

BFS (Breadth-First Search) of a graph uses a queue.

Although DFS (Depth First Search) of a graph makes use of a stack, it can also be implemented using recursion that uses function call stack.

How To Prepare for recruitment Drives 2021: Click here 

25. What is an AVL tree?

An AVL tree is a type of binary search tree that is always in a state of partially balanced. The balance is measured as a difference between the heights of the subtrees from the root. This self-balancing tree was known to be the first data structure to be designed as such.

26. Explain Greedy algorithm?

Algorithms following greedy approaches build up solutions step by step. It is mostly used in optimization problems. It makes the optimal choice at each step, to solve the entire problem.

Example: Dijkstra Algo, Prim ‘s Algo, Kruskal.

27. Explain Divide & Conquer algorithm?

Algorithms following the D & C approach works in two steps-Divide & Combine. At First we divide the problem into subparts, solve them individually and then combine the result of all subparts to get a collective solution.

Example: Binary Search, Merge Sort.

28. Explain Dynamic Programming?

DP is used to find the most optimized solution by eliminating the standard recursive calls.

Example: Finding fibonacci series.

29. What is the need of Data Structure?

It tells how data can be stored and accessed in its elementary level. It allows us to manage huge amounts of data efficiently. It provides different techniques for searching and sorting data.

30. Explain the role of malloc(), calloc(), realloc() and free()in dynamic memory allocation.

1. malloc() is one of the functions used for dynamic memory allocation. It takes up single arguments, which denotes the number of bytes to be allocated.

malloc() is faster than calloc().

Syntax : int *p = (int *)malloc(sizeof(int))

2. calloc() is one of the functions used for contiguous dynamic memory allocation. It takes up two arguments, in which the first argument denotes the number of bytes to be allocated, and the second argument denotes size of each block. It initializes allocated memory by 0.

3. The realloc() function is used to resize allocated memory without losing old data.

Syntax: void *realloc(void *p, size_t newsize);

4. free() is used to free the memory block that had been allocated dynamically.

31. List types of Linked List ?

  •  1. Singly LL
  •  2. Doubly LL
  •  3. Circular LL
  •  4. Circular Doubly LL

32. How is a linked list better than an array?

1. Array is static and Linked list is dynamic.

2. Linked list avoids memory wastage

33. What is Stack Overflow & Stack Underflow?

Stack Overflow : Condition when array is full and user requests for another insertion.

Stack Underflow : Condition when array is empty and user requests for deletion operation.

34. What is the condition of Stack Overflow?

top=n-1, where n is the number of elements in stack

35. Give some applications from stack?

  • 1. For data reversal.
  • 2. Evaluating arithmetic operations.
  • 3. To calculate postfix expressions.
  • 4. For parsing.
  • 5. For simulation of recursion.

36. What is the basic condition to check whether a circular queue is full or not?

(rear+1)%size=front

37. Explain  the concept of Priority Queue?

Priority queue is the collection of elements such that each element has been assigned a priority i.e order in which elements are deleted or processed. An element of high priority is processed before any element of lower priority.

38. What are the minimum number of queues required to implement priority queue?

2, one for data & one for priority.

39. Explain different types of binary tree?

  1. Full Binary tree : Every node has 0 or 2 children.
  2. Complete Binary tree : All internal nodes have 2 children.
  3. Perfect Binary Tree : All internal nodes have 2 children and leaf node at same level
  4. Skewed tree : Tree that goes in a single direction.
    1. Left Skewed tree : Node have only left child not right.
    2. Right Skewed tree : Node have only right child not left

40. What is the maximum number of nodes in a binary tree of height ‘h’?

2^(h+1)

41. What is the depth of a binary tree with ‘n’ nodes?

D = log(base 2)(n)+1

42.  Explain the game of Tower of Hanoi.

The Tower of Hanoi is a mathematical game or puzzle. It consists of three rods and a number of disks of different sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

43. Differentiate between B-Tree & B+ Tree?

B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree is a generalization of a binary search tree in that a node can have more than two children. In B+ Tree, each node contains keys only(not pairs), and all pointers to data records exist at leaf level only.

44. What are the different operations applied on AVL trees?

1. Left-Left Rotation (LL) : right rotate node p.

2. Left-Right Rotation (LR) : left rotate “parent of p” and right rotate “parent of parent of p (p-parent-parent)”.

3. Right-Right Rotation (RR) : left rotate node p.

4. Right-Left Rotation (RL) : right rotate “parent of p” and left rotate “parent of parent of p (p-parent-parent)”.

where p is the node with violating balance-factor.

45. Define Path & cycle?

Path represents the sequence of adjacent vertices whereas a cycle represents a closed path.

46. What are the different ways to represent a graph?

There are two ways to represent a graph, using Adjacency Matrix and Adjacency List.

47. What are the application areas of Graph data structure?

  • Circuit Designing.
  • Computer Networks.
  • In study of DNA structure of organisms.

48. What is Spanning Tree?

It is a subset of a graph, which has all the vertices covered with the minimum possible number of edges. It does not have cycles and can’t be disconnected.

49. Explain the working of selection sort?

In Selection sort, we select a minimum element from the array and store it in the appropriate position.

Time complexity for selection sort – O(n^2).

50. Explain the working of Insertion Sort?

In this, the leftmost element is considered to be already sorted. From the remaining elements, left most is taken out and is compared to already sorted elements to its left.

Get Access To Our Premium Courses
Install our application from PlayStore and get discounts on our new courses.

Pin It on Pinterest