Data Structures Interview Questions

Showing Questions 1 - 20 of 20 Questions
Sort by: 
 | 
Jump to Page:
  •  

    C Program to replication of string

    Write a c program to implement the replication of string which will be given as a command line argument?

    saurabh singh

    • Jun 19th, 2014

    Here is a simple code using command line argument to print multiple number of strings with "_" between them. To check the output , type this in command prompt : filename ABC 5 OUTPUT: ABC_ABC_ABC_ABC_ABC

    Code
    1.  
    2. #include<stdio.h>
    3. #include<stdlib.h>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7.         if(argc<2)
    8.         {
    9.                 printf("Enter CLA") ;
    10.                 return 0 ;
    11.         }
    12.        
    13.     printf("%s",argv[1]) ;
    14.          
    15.         int n = atoi(argv[2]) ;
    16.  
    17.     for(int i=0;i<n;i++)
    18.         printf("_%s ",argv[1]) ;
    19.         return 0 ;
    20.        
    21. }

    Abhishek

    • Nov 11th, 2011

    "c #include #include #include char * string_repeat( int n, const char * s ) { size_t slen = strlen(s); char * dest = calloc(n*slen+1, sizeof(char)); int i; char * p; ...

  •  

    What is the difference between bubble sort & quick sort?

    aahwini m

    • Feb 8th, 2016

    Quicksort is faster than bubble sort and the main difference is time complexity.

    Aqan12

    • May 26th, 2010

    Bubble sort is a very simple algorithm which compares two neighbouring elements and swaps them if they are not in the right order.   In a worst case scenario when the list is alrea...

  •  

    If the depth of a tree is 3 levels, then what is the Size of the Tree?

    Skill/Topic: TreeA) 8Explanation: You calculate the size of a tree by using the following formula: size = 2 ^ depth If the depth is 3 levels, then the size is 8, as shown here: 8 = 2 ^ 3

    Shubh

    • Nov 5th, 2018

    ANS 8 is correct, 7 is not listed.

    durga

    • Apr 8th, 2015

    But y v shld use 2^n or 2^n-2 formula only can any one give me the explanation