Skip to main content

Posts

Showing posts from May, 2020

PEP DATA STRUCTURE PRACTICE

DATA STRUCTURE PEP PRACTICE :  Data Structure  is a way to store and organize  data  so that it can be used efficiently .  For example, we can store a list of items using array,linked list,stack,queue,tree,graph. 1. Array : In this topic we will learn   = > --->Array Insertion   --->Array Deletion --->Array Rotation                                                                         Array Insertion   #include<iostream> using namespace std; int main() { int a[50],size,num,pos; cin>>size; if(size>50) { cout<<"overflow!!"<<endl; }else { for(int i=0;i<size;i++) { cin>>a[i]; } cin>>num>>pos; for(int i=size-1;i>=pos-1;i--) { a[i+1]=a[i]; } a[pos-1]=num; size++; for(int i=0;i<size;i++) { cout<<a[i]<<" "; } } } -----------------------------------------C omplexity(worst case) : O(n) --------------