Category Archives: Array

  • We will discuss frequently asked famous interview questions on arrays in java.
  • We will discuss famous interview questions like
    • Find intersection of two sorted arrays in java
    • Find union of two sorted arrays in java
    • Program to find leader elements in an array using java
    • Find majority element in array – Boyer Moore’s voting algorithm & many more
  • We will discuss various sorting algorithm
    • Bubble Sort
    • Insertion Sort
    • Quick Sort
    • Heap sort
    • Merge sort
    • Selection sort etc.
  • Famous search techniques like
    • Binary search algorithm.

Find second smallest element in an array of integers (java / example)

Given an array of integers in java. Print second smallest element in an array (in single iteration). We have already discussed to find out second largest element in an array of integers. Example – find second smallest element in an array of integers (java). Example 1: Given an input array  {2, 4, 6, 8, 10, 12}. Smallest element… Read More »

Implement two stacks using single array in java (example)

Given an array of integers in java. Create two stacks using single array. We shall able to perform push & pop operations on both stacks. We will create two stacks i.e. stack1 and stack2. stack1 will have following methods. push1 method: push1 method will insert the element to stack1 pop1 method: pop1 method will remove… Read More »

Create or implement stack using array in java (with example)

Create or implement stack in java using array as underlying data structure. We will create stack class having following methods Push method: Push method will be used to insert new element to stack. Pop method: Pop method will remove top element of stack. Size method: Size method will return current size of stack. isEmpty method:… Read More »