Category : dsa

enter image description here we are given a array with the index value in which ,we need to check if that index value in the array(given tree) is on correct position or not if not then place the ele on correct position and this process is called heapify. //min-heapify #include<bits/stdc++.h> using namespace std; class minHeap{ ..

Read more

I was solving this question: Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting. Consider that all the trains arrive on the same day and leave on the same day. Arrival and departure ..

Read more

Can someone tell me, why I am getting Runtime Error (SIGSEGV) in the following piece of code #include<bits/stdc++.h> using namespace std; int isFeasible(int array[], int a,int b,int k){ int j,f=1; for(int i=0;array[i]<=b;i++){ if(array[i]==a) { j=i; //cout<<j<<" "; } } //cout<<endl; while(array[j]<b){ //cout<<array[j]<<" "<<array[j+1]<<endl; if((array[j+1]-array[j])>k) f=0; j++; } return f; } int main(){ int n,k,p,l,m; cin>>n>>k>>p; ..

Read more

#include <iostream> using namespace std; typedef struct Node node; struct Node { int data; struct Node *left; struct Node *right; }; void INORDER(node *root) { if (root != NULL) { INORDER(root->left); cout << root->data; INORDER(root->right); } } void insertToTree(int nodedata, node *up) { node *newdata = (node *)malloc(sizeof(node)); newdata->data = nodedata; newdata->left = NULL; newdata->right ..

Read more