Skip to content

sanyathisside/Arrays

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARRAY


1D ARRAY

  • Efficient way to search in sorted array.
  • Find first and last occurence.
  • Binary search STL (binary_search(arr,arr+n,key)) in algorithm header file.
  • sort(a,a+n) [Quite efficient]
  • Comparator:
    • Make a compare function.
    • sort(a,a+n,compare)
  • Divide
  • Sort
  • Merge
  • Divide and conquer algorithm

Quick sort

  • Divide and conquer algorithm.
  • Choose an eleemnt as pivot element.
  • Divide in two parts(elements which are less than or equal to pivot, elements that are greater than pivot).
  • Pivot will come in the correct position.
  • Recursively sort the two parts.

Counting sort

  • When we have data which lies in a certain range.

Bucket sort

DNF sort

Wave sort

  • Continuous element
  • This involves three nested loops.

Maximum subarray sum

Given a sorted array, find pair of elements that sum to k.


2D ARRAY

  • Other method:
    • Reverse all the rows. STL also have reverse method.
    • Take transpose.

Sum of all submatrix from a given matrix

  • Approach 1: *

About

Array (data structure) implementation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages