# Array

Given a string, print the variation of string as shown below Input String: ‘hat’ Replace one character with numeric one(‘1’): ‘1at‘, ‘h1t‘, ‘ha1‘ Replace two characters with ‘1’ each: ‘11t‘, ‘h11‘, ‘1a1‘ Replace three characters with ‘1’ each: ‘111‘ In all the strings above, wherever the numeric characters are consecutive, add them. So ’11t’ will become ‘2t’, Similarly ‘111’ […]

Given two arrays of integers, write a code to check if one is permutation (arranging the same numbers differently) of elements present in the other. For example, the below two arrays are permutations of each other: int a[5] = {1, 2, 3, 4, 5}; int b[5] = {2, 1, 4, 5, 3};

Given an array containing both positive and negative integers, write code to rearrange the elements so that positive and negative numbers comes alternately. If positive (or negative) integers is not equal in number then extra positive (or negative) numbers should come at the end of array. For example: Input : {1, 2, -2, -5, 6, […]

A better implementation of Stack is usually using linked list unless you are sure of the number of elements in array. But if you are just starting with data structures and are not familiar with linked list, you can try implementing stack in an array. While using array to implement stack is easy, it has limitation that […]

This video discusses the Linear Search algorithm in detail.

This video describes Binary search algorithm.

This video describes Bubble Sort Algorithm and its optimizations.

This video describes selection sort algorithm:

Selection sort is an in-place, comparison sorting algorithm. Like bubble sort it also divides the given array in two sub arrays sorted and unsorted, divided by an imaginary wall. Initially all the elements will be in the unsorted list. Each pass will pick the smallest element from the unsorted list and add it at the end […]

What is Bubble Sort. Write algorithm of mention the Time & Space complexity of the Algorithm. Also suggest improvements which will improve the best case running time of Algorithm to O(n). Solution: Bubble Sort is a sorting algorithm which compares two adjacent elements and swap them if they are not in the right order. To […]