Posts

Showing posts from May, 2022

TREAPS

Image
 treaps= trees + heaps INRODUCTION 1.     every node in treap data structure has two main entities  first is key which is component for tree                   property and second is priority which components for min heap property. 2.     if node1 has higher property than node2 then node2 will lie below the node 1 & if key of node1 is less         than key of node2 then node1 will lie in left side of tree and node2 will lie on right side of tree. OPERATIONS 1.      Search =>  time for successfull search is proportional to depth of node & time of unsuccessfull                                         search    is proportional to depth of node. 2.     Insertion=> First we will do normal search tree insertion, then after that to make it min heap we                                       will    rotate the  nodes such that priority of that node is higher than its parent, and                                            rotate it such    a way that its depth decreases by one and de

STUDENT INFORMATION USING QRCODE

PROBLEM => we don't have a good system for identifying college students in labs,clg gates and libraries. SOLUTION =>       1. We are going to make QR CODE SYSTEM.          2. Convert the student data into QR CODE and store it in the database.     3. Make an application that will scan the QR CODE and which will display the student details. TECHNOLOGY TO BE USED => basic python and kivy BASIC PROJECT ROADMAP =>     1.Collect the data.(Profile image,mis,name,batch)     2.Convert the data into QR CODE.     3.Print the QR CODE.     4.Scan the QR CODE and display the data.

ADJACENT MATRIX

Image
 This usually used in representation of graphs.If there are n vertices in graph then there are  n rows and n columns in matrix. Let us take Ith row and Jth column then A[I][J] represents the edge between two nodes I  & J.If a[I][J] == 0 then there is no edge between node I and node J & if A[I][J] == 1 then there is edge. These type of graph representation is used when there are more number of edges.Reason is that if there are e less number of edges then lot of space will wasted in storing the zeroes which is not good thing. Following is the graph  and its adjancy matrix =>      # include < stdio.h > # include < stdlib.h > int main () {     // n is number of edges     int n ;     printf (" Enter the number of edges => ");     scanf (" %d ", & n );     // construct adjancy matrix     int adjMatrix [ n + 1 ][ n + 1 ];     // iterate for status of connected or not     for ( int i = 0 ; i < n ; i ++ )     {         for ( int j

LOWEST COMMON ANCESTOR IN BST

 PROBLEM => FIND THE LOWEST COMMON ANCESTOR OF TWO NODES (a & b) IN BINARY                                        SEARCH TREE STEPS =>  1.Find whether these two nodes are present in bst.If not found then return NULL. 2.If both nodes are found then there are 4 possibilites =>                    1.root == a || root == b => return root                    2.a is found in left subtree and b is found in right subtree => return NULL from that subtree                                  where we cant find both a & b                    3.if a and b are found in left/right subtree return root node * lca ( node * root , int a , int b ){     if ( root == NULL ) // root is NULL     {         return NULL ;     }     if ( root -> data == a || root -> data == b ) // if found numbers at current node     {         return root ;     }     node * left = lca ( root -> left , a , b ); // find in left subtree     node * right = lca ( root -> right , a ,

RAM & CPU

  1.      WHAT IS THE SIGNIFICANCE OF RAM? =>    RAM  acts as temporary memory when you are working on some software applications. They store the data which we give to the software application when we are using it, when the application is used data is lost. 2.      CPU & RAM => CPU is the brain and RAM is the memory that is used by the CPU.

REGISTERS AND RAM

 1.      Why are registers used instead of RAM? =>     Because registers are very fast computer memory which is used to execute programs and operations efficiently. STRUCTURE AND COMPONENTS OF ALL REGISTERS 1. Accumulator => Stores the value from the MDR register 2. Memory Address Register => It holds the address of the location which is to be accessed from the memory 3. Memory Data Register => It holds the data to be written into the memory of to be read out from the addressed location MAR and MDR facilitate the communication between CPU and RAM 4.General-Purpose Register => Used to store temporary data during ongoing operation 5. Program Counter => used to keep track of the execution of the program 6. Instruction Register => Holds the instruction which is to be executed currently. 7. Condition code register => It has many flags that indicate the current status of any operation.

FETCH DECODE EXECUTE CYCLE

  FDEC (FETCH DECODE AND EXECUTE CYCLE) shows how basically a computer CPU works. First understand the components of CPU => 1.      ALU (Arithmetic Logic Unit) - From its name, we come to know that it it performs arithmetic operation of CPU like addition and subtraction. 2.     PC (Program Counter) - Address where computer will look for instruction 3.     MAR (Memory Address Register) - Computer needs somewhere to store address of current instruction being executed. 4.     MDR (Memory Data Register) - Data copied from address present in MAR is stored in MDR. 5.     IR (Instruction Register) - If data in MDR is instruction then it is stored in IR . 6.     Control Unit - data from IR is fetched and decoded into two parts opcode and operand by Control Unit 7.     Acc (Accumulator) - Executed data is stored in MDR if it is not instruction then it is stored in Accumulator. FETCH : 1.      Computer will look for instruction that is present in address which is the value present in PC. 2.  

What the hell is SPARSE MATRIX?????

Image
 There are 2D arrays that contain many zeroes in them, so they take so much memory space. Sparse matrix are valid only when 2D arrays contain more zeroes than non-zero elements. So to reduce the memory space taken we do one easy trick => We make a 2D array that contains 3 arrays of N size.      WHAT IS THE VALUE OF N? => N is the number of non-zero elements present in a 2D array.      WHAT ARE THE 3 ARRAYS PRESENT IN A 2D ARRAY? =>  First Array is of the row in which that non-zero element is present.     The second Array is columns in which non-zero elements are present.     The third Array is a collection of the values of non-zero elements.                                                                                

ALGORITHM FOR CONVERTING INFIX TO POSTFIX EXPRESSION

Image
  1.      infix expression => a + b           postfix expression => ab* 2.      why to convert infix expression to postfix expression ?  =>     There are many uses of postfix expression .for eg building expression tree which is quite hectic way by doing it through infix expression. 3.      Following is the algorithm for converting infix to postfix expressionn in simple words =>          1. scan the infix string from left to right.          2.if the character is operand then simply print it.          3.if character is operator then following are the classifications =>                         1. If there is nothing in stack then simply push operator in stack                         2. If the top element has less precedence the simply push operator in stack.                         3.If top element has more precedence then pop the element and print it until top element has                                  more precedence.                         4.If the top element has equ

Time Complexity of building a heap from heapify

Image
We think that time complexity of buildHeap is o(nlogn) which wrong. Time complexity of buildHeap is o(n) How ? Let us see PROOF =>   
Image
 Today I started my visual cryptography project. 1.          What is visual cryptography? =>     Visual cryptography is a technique by which we can secure the secret msg written on an image. 2.          How visual cryptography works? =>        1.      Simple visual cryptography machine which takes the image that is to be transported safely.              2.     Then it divides that image using a certain algorithm into two images or layers.             3.     These layers are transported to the receiver and then the receiver overlaps these images.             4.     After overlapping these images the receiver gets the original message which was written                                    in  the  original image sent by the sender.             5.     Note that the image sent by the sender and image received by the receiver is not at all same bit                       by   bit b ut it is sufficient such that the receiver can understand the secret message. 3.           Let me show you

FINDING MODULO INVERSE USING FERMAT LITTLE THEOREM

Image
 

Extended Euclidean Algorithm

Image
 I was learning new cryptography topics for my college project and then I came across this amazing concept EXTEND EUCLIDEAN ALGORITHM (EEA) EEA is used in decrypting RSA. Following is the extract of EEC =>  Following is the python code for finding bezout's numbers =>  a = int ( input (" Enter A => ")) b = int ( input (" Enter B => ")) r1 = a r2 = b q = int ( r1 / r2 ) r = r1 % r2 s1 = 1 s2 = 0 s = s1 - q * s2 t1 = 0 t2 = 1 t = t1 - q * t2 while ( 1 ):     r1 = r2     r2 = r     if (r2 == 0 ):         s1 = s2         t1 = t2         break     q = int ( r1 / r2 )     r = r1 % r2     s1 = s2     s2 = s     s = s1 - q * s2     t1 = t2     t2 = t     t = t1 - q * t2 print ( r1 , s1 , t1 ) Enter A => 60 Enter B => 36 12 -1 2