id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
24,300 | data structures using middle of the array to do thiswe must first find the location from where the element has to be deleted and then move all the elements (having value greater than that of the elementone position towards left so that the space vacated by the deleted element can be occupied by rest of the elements exa... |
24,301 | programming example write program to delete number from given location in an array #include #include int main(int inposarr[ ]clrscr()printf("\ enter the number of elements in the array ")scanf("% "& )for( = ; < ; ++printf("\ arr[% " )scanf("% "&arr[ ])printf("\nenter the position from which the number has to be deleted... |
24,302 | data structures using for( = ; < ; ++if(arr[ =numfor( =ij< - ; ++arr[jarr[ + ] - printf("\ the array after deletion is ")for( = ; < ; ++printf("\ arr[% % "iarr[ ])getch()return output enter the number of elements in the array arr[ arr[ arr[ arr[ arr[ enter the number to be deleted the array after deletion is arr[ arr[ ... |
24,303 | int arr [ ]arr [ ]arr [ ]int in mindex= clrscr()printf("\ enter the number of elements in array ")scanf("% "& )printf("\ \ enter the elements of the first array")for( = ; < ; ++printf("\ arr [% " )scanf("% "&arr [ ])printf("\ enter the number of elements in array ")scanf("% "& )printf("\ \ enter the elements of the sec... |
24,304 | data structures using if we have two sorted arrays and the resultant merged array also needs to be sorted onethen the task of merging the arrays becomes little difficult the task of merging can be explained using fig array array array figure merging of two sorted arrays figure shows how the merged array is formed using... |
24,305 | if(arr [index_first]<arr [index_second]arr [indexarr [index_first]index_first++else arr [indexarr [index_second]index_second++index++/if elements of the first array are over and the second array has some elements if(index_first = while(index_second< arr [indexarr [index_second]index_second++index++/if elements of the s... |
24,306 | data structures using passing arrays to functions like variables of other data typeswe can also pass an array to function in some situationsyou may want to pass individual elements of the arraywhile in other situationsyou may want to pass the entire array in this sectionwe will discuss both the cases look at fig which ... |
24,307 | calling function called function main(void func(int *numprintf("% "*num)int arr[ ={ }func(&arr[ ]) figure (bpassing addresses of individual array elements to function passing the entire array we have discussed that in the array name refers to the first byte of the array in the memory the address of the remaining elemen... |
24,308 | data structures using programming examples write program to read an array of numbers and then find the smallest number #include #include void read_array(int arr[]int )int find_small(int arr[]int )int main(int num[ ]nsmallestclrscr()printf("\ enter the size of the array ")scanf("% "& )read_array(numn)smallest find_small... |
24,309 | int arr[ ]nclrscr()printf("\ enter the size of the array ")scanf("% "& )read_array(arrn)interchange(arrn)printf("\ the new array is")display_array(arr, )getch()return void read_array(int my_array[ ]int nint ifor( = ; < ; ++printf("\ arr[% " )scanf("% "&my_array[ ])void display_array(int my_array[ ]int nint ifor( = ; < ... |
24,310 | data structures using return posoutput enter the size of the array arr[ arr[ arr[ arr[ arr[ the new array is arr[ arr[ arr[ arr[ arr[ pointers and arrays arr[ arr[ arr[ arr[ arr[ figure memory representation of the concept of array is very much bound to the concept of pointer consider fig for exampleif we have an array... |
24,311 | is pointer variableso when we write ptr+ithen adding gives pointer that points elements further along an array than the original pointer since ++ptr and ptr+are both equivalent to ptr+ incrementing pointer using the unary +operatorincrements the address it stores by the amount given by sizeof(typewhere type is the data... |
24,312 | data structures using in we can add or subtract an integer from pointer to get new pointerpointing somewhere other than the original position also permits addition and subtraction of two pointer variables for examplelook at the code given below int main(int arr[]={ , , , , , , , , }int *ptr *ptr ptr arrptr arr+ printf(... |
24,313 | int *ptr[ ]int ptr[ &pptr[ &qptr[ &rptr[ &sptr[ &tcan you tell what will be the output of the following statementprintf("\ % "*ptr[ ])the output will be because ptr[ stores the address of integer variable and *ptr[ will therefore print the value of that is now look at another code in which we store the address of three... |
24,314 | data structures using in the above statementa two-dimensional array called marks has been declared that has ( rows and ( columns the first element of the array is denoted by marks[ ][ ]the second element as marks[ ][ ]and so on heremarks[ ][ stores the marks obtained by the first student in the first subjectmarks[ ][ s... |
24,315 | in one-dimensional arrayswe have seen that the computer does not keep track of the address of every element in the array it stores only the address of the first element and calculates the address of other elements from the base address (address of the first elementsame is the case with two-dimensional array here alsoth... |
24,316 | data structures using the individual elements of two-dimensional array can be initialized using the assignment operator as shown here marks[ ][ or marks[ ][ marks[ ][ accessing the elements of two-dimensional arrays the elements of array are stored in contiguous memory locations in case of one-dimensional arrayswe used... |
24,317 | getch()return printf("\ % "arr[ ][ ])output in small company there are five salesmen each salesman is supposed to sell three products write program using array to print (ithe total sales by each salesman and (iitotal sales of each item #include #include int main(int sales[ ][ ]ijtotal_sales= //input data printf("\ ente... |
24,318 | data structures using enter the sales of items sold by salesman total sales by salesman total sales by salesman total sales by salesman total sales by salesman total sales by salesman total sales of item total sales of item total sales of item write program to read array marks which stores the marks of five students in... |
24,319 | marks[ ][ marks[ ][ marks[ ][ the highest marks obtained in the subject the highest marks obtained in the subject the highest marks obtained in the subject operations on two-dimensional arrays two-dimensional arrays can be used to implement the mathematical concept of matrices in mathematicsa matrix is grid of numbersa... |
24,320 | data structures using printf("\ % ",mat[ ][ ])return output enter the elements of the matrix the elements of the matrix are write program to transpose matrix #include #include int main(int ijmat[ ][ ]transposed_mat[ ][ ]clrscr()printf("\ enter the elements of the matrix ")for( = ; < ; ++for( = ; < ; ++scanf("% "&mat[ ]... |
24,321 | write program to input two yn matrices and then calculate the sum of their corresponding elements and store it in third yn matrix #include #include int main(int ijint rows cols rows cols rows_sumcols_sumint mat [ ][ ]mat [ ][ ]sum[ ][ ]clrscr()printf("\ enter the number of rows in the first matrix ")scanf("% ",&rows )p... |
24,322 | data structures using output enter the number of rows in the first matrix enter the number of columns in the first matrix enter the number of rows in the second matrix enter the number of columns in the second matrix enter the elements of the first matrix enter the elements of the second matrix the elements of the resu... |
24,323 | res[ ][ ]= for( = <res_cols; ++res[ ][ +mat [ ][kmat [ ][ ]printf("\ the elements of the product matrix are ")for( = ; <res_rows; ++printf("\ ")for( = ; <res_cols; ++printf("\ % ",res[ ][ ])return output enter the number of rows in the first matrix enter the number of columns in the first matrix enter the number of row... |
24,324 | data structures using calling function called function main(void func(int arr[]int ifor( ; < ; ++printf("% "arr[ )int arr[ ][ ({ }{ })func(arr[ ])figure passing row of array to function passing the entire array to pass two-dimensional array to functionwe use the array name as the actual parameter (the way we did in cas... |
24,325 | for( = <ri++printf("\ ")for( = <rj++printf("\ % "mat[ ][ ])output enter the number of rows and columns of the matrix - pointers and two-dimensional arrays consider two-dimensional array declared as int mat[ ][ ]to declare pointer to two-dimensional arrayyou may write int **ptr here int **ptr is an array of pointers (to... |
24,326 | data structures using in this casearr has type int *since all pointers have the same sizethe address of ptr can be calculated asaddr(ptr iaddr(ptr[sizeof(int *iaddr(ptr[ isince arr has type int **arr[ &arr[ ][ ]arr[ &arr[ ][ ]and in generalarr[ &arr[ ][ according to pointer arithmeticarr arr[ ]yet this skips an entire ... |
24,327 | programming example write program to read and display matrix #include #include void display(int (*)[ ])int main(int ijmat[ ][ ]clrscr()printf("\ enter the elements of the matrix")for( = ; < ; ++for( ++scanf("% "&mat[ ][ ])display(mat)return void display(int (*mat)[ ]int ijprintf("\ the elements of the matrix are")for( ... |
24,328 | data structures using using indices an -dimensional ym ym yymn array is collection of ym ym yymn elements in multi-dimensional arraya particular element is specified by using subscripts as [ ][ ][ [in]where < < < in <mn multi-dimensional array can contain as many indices as needed and as the requirement of memory incre... |
24,329 | programming example write program to read and display array #include #include int main(int array[ ][ ][ ]ijkclrscr()printf("\ enter the elements of the matrix")for( = ; < ; ++for( = ; < ; ++for( = ; < ; ++scanf("% "&array[ ][ ][ ])printf("\ the matrix is ")for( = ; < ; ++printf("\ ")for( = ; < ; ++printf("\ ")for( = ; ... |
24,330 | data structures using pointer to three-dimensional array can be declared asint arr[ ][ ][ ]={ , , , , , , , }int (*parr)[ ][ ]parr arrwe can access an element of three-dimensional array by writingarr[ ][ ][ *(*(*(arr+ )+ )+kprogramming example write program which illustrates the use of pointer to three-dimensional arra... |
24,331 | - - - figure - lower-triangular matrix there are two types of sparse matrices in the first type of sparse matrixall elements above the main diagonal have zero value this type of sparse matrix is also called (lowertriagonal matrix because if you see it pictoriallyall the elements with non-zero value appear below the dia... |
24,332 | data structures using points to remember an array is collection of elements of the same data type the elements of an array are stored in consecutive memory locations and are referenced by an index (also known as the subscriptthe index specifies an offset from the beginning of the array to the element being referenced d... |
24,333 | (ahow many elements would be moved if the name andrew has to be added in it( (ii (iii (iv (bhow many elements would be moved if the name esha has to be deleted from it( (ii (iii (iv what happens when an array is initialized with (afewer initializers as compared to its size(bmore initializers as compared to its sizeprog... |
24,334 | data structures using multiple-choice questions if an array is declared as arr[{ , , , , }then what is the value of sizeof(arr[ ])( ( ( ( if an array is declared as arr[{ , , , , }then what is the value of arr[ ]( ( ( ( if an array is declared as double arr[ ]how many bytes will be allocated to it( ( ( ( if an array is... |
24,335 | strings learning objective in the last we discussed array of integers taking step furtherin this we will discuss array of characters commonly known as strings we will see how strings are storeddeclaredinitializedand accessed we will learn about different operations that can be performed on strings as well as about arra... |
24,336 | char str["hello"char ch ' ' \ end of string beginning of string here is character not string the character requires only one memory location char str[" "char str["" \ \ here is string not character the string requires two memory locations one to store the character and another to store the null character empty string a... |
24,337 | in such casesthe compiler creates an array of size stores "helloin it and finally terminates the string with null character rest of the elements in the array are automatically initialized to null now consider the following statementschar str[ ]str "hello"the above initialization statement is illegal in and would genera... |
24,338 | data structures using writing strings strings can be displayed on the screen using the following three ways using printf(function using puts(functionand using putchar(function repeatedly strings can be displayed using printf(by writing printf("% "str)we use the format specifier % to output string observe carefully that... |
24,339 | once we encounter the null characterthe control jumps out of the while loop and the length is initialized with the value of note the library function strlen( which is defined in string returns the length of string programming example write program to find the length of string #include #include int main(char str[ ] leng... |
24,340 | data structures using programming example write program to convert the lower case characters of string into upper case #include #include int main(char str[ ]upper_str[ ]int = clrscr()printf("\ enter the string :")gets(str)while(str[ !'\ 'if(str[ ]>=' &str[ ]<=' 'upper_str[istr[ else upper_str[istr[ ] ++upper_str[ '\ 'p... |
24,341 | copied into the destination string starting from that position finallya null character is added to terminate the destination string programming example write program to append string to another string #include #include int main(char dest_str[ ]source_str[ ]int = = clrscr()printf("\ enter the source string ")gets(source... |
24,342 | data structures using figure algorithm to compare two strings programming example write program to compare two strings #include #include #include int main(char str [ ]str [ ]int = len = len = same= clrscr()printf("\ enter the first string ")gets(str )printf("\ enter the second string ")gets(str )len strlen(str )len str... |
24,343 | if(len !=len printf("\ the two strings are not equal")if(same = if(str [ ]>str [ ]printf("\ string is greater than string ")else if(str [ ]<str [ ]printf("\ string is greater than string ")getch()return output enter the first string hello enter the second string hello the two strings are equal reversing string if "hell... |
24,344 | data structures using str[jstr[ ]str[itempi++ --printf("\ the reversed string is ")puts(str)getch()return output enter the stringhi there the reversed string isereht ih extracting substring from string to extract substring from given stringwe need the following three parameters the main string the position of the first... |
24,345 | substr[jstr[ ] ++ ++ --substr[ '\ 'printf("\ the substring is ")puts(substr)getch()return output enter the main string hi there enter the position from which to start the substring enter the length of the substring the substring is th step [initializeset ijand kstep repeat steps to while text[ !null step if pos repeat ... |
24,346 | data structures using if( ==poswhile(str[ !'\ 'ins_text[jstr[ ] ++ ++else ins_text[jtext[ ] ++ ++ins_text[ '\ 'printf("\ the new string is ")puts(ins_text)getch()return output enter the main text newsman enter the string to be inserted paper enter the position at which the string has to be inserted the new string isnew... |
24,347 | with the characters of text to find if the characters are same if it is not the casethen we move to step where is incremented if the string is foundthen the index is initialized with ielse it is set to - for exampleif text welcome to the world string come in the first pass of the inner loopwe will compare come with wel... |
24,348 | data structures using if(str[ ]=='\ 'copy_loop=knew_text[ntext[copy_loop] ++copy_loop++ ++new_str[ ]='\ 'printf("\ the new string is ")puts(new_str)getch()return output enter the main text hellohow are youenter the string to be deleted how are youthe new string is hello replacing pattern with another pattern in string ... |
24,349 | ++ ++if(pat[ ]=='\ 'copy_loop=kwhile(rep_pat[rep_index!='\ 'new_str[nrep_pat[rep_index]rep_index++ ++new_str[nstr[copy_loop] ++copy_loop++ ++new_str[ ]='\ 'printf("\ the new string is ")puts(new_str)getch()return output enter the string how are youenter the pattern to be replaced are enter the replacing pattern are the... |
24,350 | data structures using step [initializeset istep repeat step while in step apply process to names[ [end of loopstep exit figure algorithm to process individual string from an array of strings by declaring the array nameswe allocate bytes but the actual memory occupied is bytes thuswe see that about half of the memory al... |
24,351 | #include int main(char str[ ]int = word_count line_count = char_count clrscr()printf("\ enter '*to end")printf("\ **************")printf("\ enter the text ")scanf("% "&str[ ])while(str[ !'*' ++scanf("% "&str[ ])str[ '\ ' = while(str[ !'\ 'if(str[ ='\ | == line_count++if(str[ =&&str[ + !'word_count++char_count++ ++print... |
24,352 | data structures using if(str[ =str[ ] ++ --else breakif( >=jprintf("\ palindrome")else printf("\ not palindrome")return output enter the stringmadam palindrome pointers and strings in cstrings are treated as arrays of characters that are terminated with binary zero character (written as '\ 'considerfor examplechar str[... |
24,353 | in this programwe declare character pointer *pstr to show the string on the screen we then point the pointer pstr to str thenwe print each character of the string using the while loop instead of using the while loopwe could straightaway use the function puts()as shown below puts(pstr)the function prototype for puts(is ... |
24,354 | data structures using *pcopy_str *pstrpstr++pcopy_str++*pcopy_str '\ 'printf("\ the copied text is ")while(*pcopy_str !'\ 'printf("% "*pcopy_str)pcopy_str++return output enter the string programming the copied text is programming write program to concatenate two strings #include #include int main(char str [ ]str [ ]cop... |
24,355 | points to remember string is null-terminated character array individual characters of strings can be accessed using subscript that starts from zero all the characters of string are stored in successive memory locations strings can be read by user using three waysusing scanf(functionusing gets(functionor using getchar(f... |
24,356 | data structures using write program to count the number of digitsupper case characterslower case charactersand special characters in given string write program to count the total number of occurrences of given character in the string write program to accept text count and display the number of times the word 'theappear... |
24,357 | "hi" "hello" "byehow can we concatenate the three strings(astrcat( , , (bstrcat( (strcat( , ))(cstrcpy( strcat( , ) strlen("oxford university press"is ( ( ( ( which function adds string to the end of another string(astradd((bstrcat((cstrtok((dstrcpy(true or false string hello world can be read using scanf( string when ... |
24,358 | structures and unions learning objective today' modern applications need complex data structures to support them structure is collection of related data items of different data types it extends the concept of arrays by storing related information of heterogeneous data types together under single name it is useful for a... |
24,359 | programming tip do not forget to place semicolon after the declaration of structures and unions }data_type var-namefor exampleif we have to define structure for studentthen the related information for student probably would beroll_numbernamecourseand fees this structure can be declared asstruct student int r_nochar nam... |
24,360 | data structures using alternate name is given to known data type the general syntax of using the typedef keyword is given asprogramming tip does not allow declaration of variables at the time of creating typedef definition so variables must be declared in an independent statement typedef existing_data_type new_data_typ... |
24,361 | struct struct_name struct_var {constant constant constant }for examplewe can initialize student structure by writingprogramming tip struct student int r_nochar name[ ]char course[ ]float fees}stud { "rahul""bca" }it is an error to assign structure of one type to structure of another type orby writingstruct student stud... |
24,362 | data structures using note statement of all the operators ->)and [have the highest priority this is evident from the following stud fees+will be interpreted as (stud fees)+copying and comparing structures we can assign structure to another structure of the same type for exampleif we have two structure variables stud an... |
24,363 | printf("\ dob % "stud dob)getch()return output enter the roll number enter the name rahul enter the fees enter the dob ********student' details ******roll no name rahul fees dob write program to readdisplayaddand subtract two complex numbers #include #include int main(typedef struct complex int realint imag}complexcomp... |
24,364 | data structures using % +%di",sum_c realsum_c imag)breakcase sub_c real real realsub_c imag imag imagprintf("\ the difference between two complex numbers is :% +%di"sub_c realsub_c imag)break}while(option ! )getch()return output *******main menu ********because of constraint of read the complex numbers spacewe will sho... |
24,365 | name namechar course[ ]date dobfloat feesstudentin this examplewe see that the structure student contains two other structuresname and date both these structures have their own fields the structure name has three fieldsfirst_namemid_nameand last_name the structure date also has three fieldsddmmand yywhich specify the d... |
24,366 | data structures using printf("\ ********student' details *******")printf("\ roll no % "stud roll_no)printf("\ name % "stud name)printf("\ fees % "stud fees)printf("\ dob % % % "stud date daystud date monthstud date year)getch()return output enter the roll number enter the name rahul enter the fees enter the dob *******... |
24,367 | stud[icourse "mca"stud[ifees in order to initialize the array of structure variables at the time of declarationwe can write as followsstruct student stud[ {{ "aman""bca" },{ "aryan""bca" }{ "john""bca" }}programming example write program to read and display the information of all the students in class then edit the det... |
24,368 | data structures using scanf("% "&new_fees)printf("\ enter the new dob ")gets(new_dob)stud[numroll_no new_rolnostrcpy(stud[numnamenew_name)stud[numfees new_feesstrcpy (stud[numdobnew_dob)for( = ; < ; ++printf("\ ********details of student % *******" + )printf("\ roll no % "stud[iroll_no)printf("\ name % "stud[iname)prin... |
24,369 | passing individual members passing structures to functions passing the entire structure passing the address of structure figure different ways of passing structures to functions passing individual members to pass any individual member of structure to functionwe must use the direct selection operator to refer to the ind... |
24,370 | data structures using }pointvoid display(point)int main(point { }display( )return void display(point pprintf("the coordinates of the point are% % " xp )programming example write program to readdisplayaddand subtract two distances distance must be defined using kms and meters #include #include typedef struct distance in... |
24,371 | case add_distance( )printf("\ the sum of two distances is % kms % meters" kmsd meters)breakcase subtract_distance( )printf("\ the difference between two distances is % kms % meters" kmsd meters)break}while(option ! )getch()return distance add_distance(distance distance distance sumsum meters meters meterssum kms kms km... |
24,372 | data structures using enter your option enter the first distance in kms and meters enter the second distance in kms and meters enter your option the sum of two distances is kms meters enter your option let us summarize some points that must be considered while passing structure to the called function if the called func... |
24,373 | programming examples write program to initialize the members of structure by using pointer to the structure #include #include struct student int r_nochar name[ ]char course[ ]int fees}int main(struct student stud *ptr_stud clrscr()ptr_stud &stud printf("\ enter the details of the student :")printf("\ enter the roll num... |
24,374 | data structures using int inprintf("\ enter the number of students ")scanf("% "& )for( = ; < ; ++ptr_stud[ (struct student *)malloc(sizeof(struct student))printf("\ enter the data for student % " + )printf("\ roll no ")scanf("% "&ptr_stud[ ]->r_no)printf("\ name")gets(ptr_stud[ ]->name)printf("\ course")gets(ptr_stud[ ... |
24,375 | printf("\ name")gets(ptr->name)printf("\ course")gets(ptr->course)printf("\ fees")scanf("% "&ptr->fees)display(ptr)getch()return void display(struct student *ptrprintf("\ details of student")printf("\ roll no % "ptr->r_no)printf("\ name % "ptr->name)printf("\ course % "ptr->course)printf("\ fees % "ptr->fees)output ent... |
24,376 | data structures using programming tip it is an error to use structureunion variable as member of its own struct type structure or union type unionrespectively declaring union the syntax for declaring union is the same as that of declaring structure the only difference is that instead of using the keyword structthe keyw... |
24,377 | the coordinates of are and in this codepoint is structure name and point is union name howeverboth the declarations are almost same (except the keywords--struct and unionin main()we can see the difference between structures and unions while initializing values the fields of union cannot be initialized all at once look ... |
24,378 | data structures using points[ points[ for( = ; < ; ++printf("\ coordinates of point[%dare % and % "ipoints[ixpoints[iy)return output coordinates of point[ are and coordinates of point[ are and coordinates of point[ are and unions inside structures generallyunions can be very useful when declared inside structure consid... |
24,379 | points to remember structure is user-defined data type that can store related information (even of different data typestogether structure is declared using the keyword structfollowed by the structure name the structure definition does not allocate any memory or consume storage space it just gives template that conveys ... |
24,380 | data structures using display the name of the students who have secured less than of the aggregate modify question to print each student' average marks and the class average (that includes average of all the student' marks make an array of students as illustrated in question and write program to display the details of ... |
24,381 | the function must receive one parameter which is structure that contains the type of figure and the size of the components needed to calculate the area must be part of union note that circle requires just one componentrectangle requires two components and triangle requires the size of three components to calculate the ... |
24,382 | linked lists learning objective linked list is collection of data elements called nodes in which the linear representation is given by links from one node to the next node in this we are going to discuss different types of linked lists and the operations that can be performed on these lists introduction we have studied... |
24,383 | structures thusit acts as building block to implement data structures such as stacksqueuesand their variations linked list can be perceived as train or sequence of nodes in which each node contains one or more data fields and pointer to the next node start figure simple linked list in fig we can see linked list in whic... |
24,384 | data structures using would denote the end of the linked list when we traverse data and next in this mannerwe finally see that the linked list in the above example stores characters that when put together form the word hello note that fig shows chunk of memory locations which range from to the shaded portion contains d... |
24,385 | roll no name aggregate grade next ram distinction shyam first division mohit outstanding rohit varun distinction outstanding karan first division veena second division - meera first division krish kusum third division outstanding silky first division start monica distinction ashish first division gaurav first division ... |
24,386 | data structures using start (biologyroll no marks next start marks - (biology (afigure next roll no - ( (astudentslinked list and (blinked list after the insertion of new student' record we have seen that every linked list has pointer variable start which stores the address of the first node of the list likewisefor the... |
24,387 | their address to the free poolso that these cells can be reused by other programs this process is called garbage collection there are different types of linked lists which we will discuss in the next section singly linked lists singly linked list is the simplest type of linked list in which every node contains some dat... |
24,388 | data structures using figure shows the algorithm to search linked list in step we initialize the pointer variable ptr with start that contains the address of the first node in step while loop is executed which will compare every node' data with val for which the search is being made if the search is successfulthat isva... |
24,389 | start allocate memory for the new node and initialize its data part to add the new node as the first node of the list by making the next part of the new node contain the address of start start now make start to point to the first node of the list start figure inserting an element at the beginning of linked list step if... |
24,390 | data structures using start allocate memory for the new node and initialize its data part to and next part to null take pointer variable ptr which points to start startptr move ptr so that it points to the last node of the list start ptr add the new node after the node pointed by ptr this is done by storing the address... |
24,391 | start allocate memory for the new node and initialize its data part to take two pointer variables ptr and preptr and initialize them with start so that startptrand preptr point to the first node of the list start ptr preptr move ptr and preptr until the data part of preptr value of the node after which insertion has to... |
24,392 | data structures using this nodein steps and we change the next pointers in such way that the new node is inserted before the desired node start allocate memory for the new node and initialize its data part to initialize preptr and ptr to the start node start ptr preptr move ptr and preptr until the data part of ptr val... |
24,393 | start make start to point to the next node in sequence start figure deleting the first node of linked list figure shows the algorithm to delete the first node from linked list in step we check if the linked list exists or not if start nullthen it signifies that there are no nodes in the list and the control is transfer... |
24,394 | data structures using step if start null write underflow go to step [end of ifstep set ptr start step repeat steps and while ptr -next !null step set preptr ptr step set ptr ptr -next [end of loopstep set preptr -next null step free ptr step exit figure algorithm to delete the last node deleting the node after given no... |
24,395 | step if start null write underflow go to step [end of ifstep set ptr start step set preptr ptr step repeat steps and while preptr -data !num step set preptr ptr step set ptr ptr -next [end of loopstep set temp ptr step set preptr -next ptr -next step free temp step exit figure algorithm to delete the node after given n... |
24,396 | data structures using printf("\ delete node from the end")printf("\ delete given node")printf("\ delete node after given node")printf("\ delete the entire list")printf("\ sort the list")printf("\ exit")printf("\ \ enter your option ")scanf("% "&option)switch(optioncase start create_ll(start)printf("\ linked list create... |
24,397 | while(ptr->next!=nullptr=ptr->nextptr->next new_nodenew_node->next=nullprintf("\ enter the data ")scanf("% "&num)return startstruct node *display(struct node *startstruct node *ptrptr startwhile(ptr !nullprintf("\ % "ptr -data)ptr ptr -nextreturn startstruct node *insert_beg(struct node *startstruct node *new_nodeint n... |
24,398 | data structures using preptr ptrptr ptr -nextpreptr -next new_nodenew_node -next ptrreturn startstruct node *insert_after(struct node *startstruct node *new_node*ptr*preptrint numvalprintf("\ enter the data ")scanf("% "&num)printf("\ enter the value after which the data has to be inserted ")scanf("% "&val)new_node (str... |
24,399 | while(ptr -data !valpreptr ptrptr ptr -nextpreptr -next ptr -nextfree(ptr)return startstruct node *delete_after(struct node *startstruct node *ptr*preptrint valprintf("\ enter the value after which the node has to deleted ")scanf("% "&val)ptr startpreptr ptrwhile(preptr -data !valpreptr ptrptr ptr -nextpreptr -next=ptr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.