Basic Coding Interview Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is a Deque?

A deque is a double-ended queue. This is a structure in which elements can be inserted or removed from either end.

What is a Graph?

A graph is a particular type of data structure that contains a set of ordered pairs. The ordered pairs in a graph are also known as edges or arcs and are most commonly used to connect nodes where the data can be stored and retrieved.

What is a Queue?

A queue refers to a linear data structure that performs operations in a FIFO order. In a queue, the least recently added elements are removed first as opposed to a stack

What is a Stack?

A stack refers to a linear data structure performing operations in a LIFO (Last In First Out) order. In a stack, elements can only be accessed, starting from the topmost to the bottom element.

What is an Array?

An array is commonly referred to as a collection of items stored at contiguous memory locations. Items stored are of the same type. It organizes data so that a related set of values can be easily sorted or searched.

Explain Doubly Linked Lists?

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

What is FIFO?

FIFO stands for First In First Out. It is a way of accessing, storing and retrieving data. The data that was stored first is extracted first.

What is LIFO?

LIFO is an abbreviation for Last In First Out It is a way of accessing, storing and retrieving data. It extracts the data that was stored last first.

How does variable declaration affect memory?

The amount of memory that is to be reserved or allocated depends on the data type being stored in that variable. For example, if a variable is declared to be "integer type", 32 bits of memory storage will then be reserved for that particular variable.

Non-linear data structure

It is a structure in which each data element can connect to over two adjacent data elements Examples of nonlinear data structure include graphs and trees

What are the concepts introduced in OOPs?

Object - A real-world entity having a particular state and behavior. We can define it as an instance of a class. Class - A logical entity that defines the blueprint from which an object can be created or instantiated. Inheritance - A concept that refers to an object gaining all the properties and behaviors of a parent object. It provides code reusability. Polymorphism - A concept that allows a task to be performed in different ways. In Java, we use method overloading and method overriding to achieve polymorphism. Abstraction - A concept that hides the internal details of an application and only shows the functionality. In Java, we use abstract class and interface to achieve abstraction. Encapsulation - A concept that refers to the wrapping of code and data together into a single unit.

Array

On the other hand, Arrays do not follow a specific order, but instead can be accessed or called by referring to the indexed element within the array.

What is Recursion?

Recursion refers to a function calling itself based on a terminating condition. It uses LIFO and therefore makes use of the stack data structure. The next couple of coding interview questions will explore your knowledge of OOPs.

Stack

Stack follows a Last In First Out (LIFO) pattern. What this means is that data access necessarily follows a particular sequence where the last data to be stored is the first one that will be extracted.

How do you reverse a string in Java?

String str = "hello"; String reverse = ""; int length = str.length(); for (int i = 0; i < length; i++) { reverse = str.charAt(i) + reverse; } System.out.println(reverse);

Which sorting algorithm is the best?

There are many types of sorting algorithms: bubble sort, quick sort, balloon sort, merge sort, radix sort, and more. No algorithm can be considered as the best or fastest because they have designed each for a specific type of data structure where it performs the best

. How do you determine if a string is a palindrome?

if (str.equals(reverse)) { System.out.println("Palindrome"); } else { System.out.println("Not Palindrome"); }

Find the number of occurrences of a character in a String?

int count = 0; char search = 'a'; for (int i = 0; i < length; i++) { if (str.charAt(i) == search) { count++; } } System.out.println(count);

Explain what a Binary Search Tree is.

A binary search tree is used to store data in a manner that it can be retrieved very efficiently. The left sub-tree contains nodes whose keys are less than the node's key value. The right sub-tree contains nodes whose keys are greater than or equal to the node's key value

What are Binary Trees?

A binary tree is an extension of the linked list structure where each node has at most two children. A binary tree has two nodes at all times, a left node and a right node.

What is a Data Structure?

A data structure is a storage format that defines the way data is stored, organized, and manipulated. Some popular data structures are Arrays, Trees, and Graphs.

What are dynamic data structures?

Dynamic data structures have the feature where they expand and contract as a program runs. It provides a very flexible method of data manipulation because adjusts based on the size of the data to be manipulated. These 20 coding interview questions that test the conceptual understanding of the candidates give the interview a clear idea on how strong the candidate's fundamentals are

Linear data structure

It is a structure in which data elements are adjacent to each other Examples of linear data structure include linked lists, arrays, queues, and stacks

What is a Linked List?

Like an array, a linked list refers to a linear data structure in which the elements are not necessarily stored in a contiguous manner. It is basically a sequence of nodes, each node points towards the next node forming a chain-like structure.

10. What is the OOPs concept?

OOPs stands for Object-Oriented Programming System, a paradigm that provides concepts such as objects, classes, and inheritance.


Ensembles d'études connexes

Managerial Accounting Practice Exam 3 pt.2

View Set

Professional Practice and Building Laws: Preboard

View Set

Select All That Apply Comprehensive

View Set

Final Study Questions- Helminths (Ch. 23)

View Set

Developmental Psych (HDEV) Chapter 8: Early Childhood: Social and Emotional Development

View Set

Business Law Honors Final - Bowen

View Set

Quiz-Quiz-Trade: Element, Compound or Mixture?

View Set

Chapter 23 PrepU and Chapter info

View Set

Chapter 3 True/False Linear Algebra

View Set