0% found this document useful (0 votes)
54 views39 pages

C - Programme by Real

The code defines a main function that: 1. Declares an integer array a with 5 elements initialized to values. 2. Declares three integer variables i, j, m. 3. Assigns values to i, j, m using pre/post-increment operations on array elements. 4. Prints the values of i, j, m. The output of the program is 3, 2, 15.

Uploaded by

Sahidulla Ayon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views39 pages

C - Programme by Real

The code defines a main function that: 1. Declares an integer array a with 5 elements initialized to values. 2. Declares three integer variables i, j, m. 3. Assigns values to i, j, m using pre/post-increment operations on array elements. 4. Prints the values of i, j, m. The output of the program is 3, 2, 15.

Uploaded by

Sahidulla Ayon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

#include<stdio.

h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array with
a size of 5 and it is initialized to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25 .
Step 2: int i, j, m; The variable i,j,m are declared as an integer type.
Step 3: i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4: j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5: m = a[i++]; becomes m = a[2]; Hence m = 15 and i is incremented by 1(i++ means
2++ so i=3)
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the variables i, j, m
Hence the output of the program is 3, 2, 15

First understand the logic of post and pre increment.....if ++x means x is incremented by 1 and gets
stored in X.

Let
x=1
y=++x and
y=x++
in first case y will be 2 and x will be 2.(that is X is incremented first and then stored in y)
in second case y will be 1 and x will be 2.(that is x is stored in y and the incremented)
try to understand this logic first..........

Similarly,
in the stmt , i = ++a[1];
since a[1]=1, then after execution of the above stmt,
i will be 2,a[1] will be 2
similarly,
in the stmt , j = a[1]++;
since a[2]=2 now(after execution of I stmt,)
j ll be 2 (post increment will happen) and a[2] will be 3 now..
in the 5th case,
m = a[i++], i is post incremented... so a[i] will be a[2] and i will be 3... so m=a[2]=15
his set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Array and Array
Operations”.

1. Which of these best describes an array?

a) A data structure that shows a hierarchical behaviour

b) Container of objects of similar types

c) Arrays are immutable once initialised

d) Array is not a data structure

Answer: b
Explanation: Array contains elements only of the same type.

3. How do you instantiate an array in Java?

a) int arr[] = new int(3);

b) int arr[];

c) int arr[] = new int[3];

d) int arr() = new int(3);

View Answer

Answer: c

Explanation: Note that option b is declaration whereas option c is to instantiate an array.

4. Which of the following is a correct way to declare a multidimensional array in Java?

a) int[] arr;

b) int arr[[]];

c) int[][]arr;

d) int[[]] arr;

View Answer

Answer: c

Explanation: The syntax to declare multidimensional array in java is either int[][] arr; or int arr[][];
7. When does the Array Index Out Of Bounds Exception occur?

a) Compile-time

b) Run-time

c) Not an error

d) Not an exception at all

Answer: b

Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the compilation is error-free.

8. Which of the following concepts make extensive use of arrays?

a) Binary trees

b) Scheduling of processes

c) Caching

d) Spatial locality

View Answer

Answer: d

Explanation: Whenever a particular memory location is referred, it is likely that the locations nearby are
also referred, arrays are stored as contigous blocks in memory, so if you want to access array elements,
spatial locality makes it to access quickly.

11. Assuming int is of 4bytes, what is the size of int arr[15];?

a) 15

b) 19

c) 11

d) 60

Answer: d

Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.
1.

Which of the following languages is more suited to a structured program?

A. PL/1

B. FORTRAN

C. BASIC

D. PASCAL

E. None of the above

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

The tracks on a disk which can be accessed without repositioning the R/W heads is

A. Surface

B. Cylinder

C. Cluster

D. All of the above

E. None of the above

2. If the two strings are identical, then strcmp() function returns

A. -1

B. 1

C. 0

D. Yes

Answer: Option C
Explanation:

Declaration: strcmp(const char *s1, const char*s2);

The strcmp return an int value that is

if s1 < s2 returns a value < 0

if s1 == s2 returns 0

if s1 > s2 returns a value > 0

10. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to
convert the expression from infix to postfix notation.

The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of
this expression?

a) 1

b) 2

c) 3

d) 4

View Answer

Answer: d

Explanation: When we perform the conversion from infix to postfix expression +, *, (, * symbols are
placed inside the stack. A maximum of 4 symbols are identified during the entire conversion.

5. What is the advantage of a multidimensional array over pointer array?

a) Predefined size

b) Input can be taken from user

c) Faster Access
d) All of the mentioned

Answer: d

6. Which of the following operation is possible using a pointer char? (Assuming the declaration is char
*a;)

a) Input via %s

b) Generation of the multidimensional array

c) Changing address to point at another location

d) All of the mentioned

View Answer

Answer: c

Explanation: None.

1. C99 standard guarantees uniqueness of __________ characters for internal names.

a) 31

b) 63

c) 12

d) 14

View Answer

Answer: b

Explanation: ISO C99 compiler may consider only first 63 characters for internal names.

3. Which of the following is not a valid variable name declaration?

a) int __a3;

b) int __3a;

c) int __A3;

d) None of the mentioned

View Answer
Answer: d

Explanation: None.

6. All keywords in C are in ____________

a) LowerCase letters

b) UpperCase letters

c) CamelCase letters

d) None of the mentioned

View Answer

Answer: a

Explanation: None.

7. Variable name resolution (number of significant characters for the uniqueness of variable) depends
on ___________

a) Compiler and linker implementations

b) Assemblers and loaders implementations

c) C language

d) None of the mentioned

View Answer

Answer: a

Explanation: It depends on the standard to which compiler and linkers are adhering.

8. Which of the following is not a valid C variable name?

a) int number;

b) float rate;

c) int variable_count;
d) int $main;

View Answer

Answer: d

Explanation: Since only underscore and no other special character is allowed in a variable name, it
results in an error.

8. Which of the following cannot be a variable name in C?

a) volatile

b) true

c) friend

d) export

View Answer

Answer: a

Explanation: volatile is C keyword.

#include <stdio.h>

int main()

int ThisIsVariableName = 12;

int ThisIsVariablename = 14;

printf("%d", ThisIsVariablename);

return 0;

a) The program will print 12

b) The program will print 14

c) The program will have a runtime error

d) The program will cause a compile-time error due to redeclaration


View Answer

Answer: b

Explanation: Variable names ThisIsVariablename and ThisIsVariableName are both distinct as C is case
sensitive.

Output:

$ cc pgm4.c

$ a.out

14

#include <stdio.h>

int main()

int a[5] = {1, 2, 3, 4, 5};

int i;

for (i = 0; i < 5; i++)

if ((char)a[i] == '5')

printf("%d\n", a[i]);

else

printf("FAIL\n");

Answer: d
Explanation: The ASCII value of 5 is 53, the char type-casted integral value 5 is 5 only.
Output:
$ cc pgm1.c
$ a.out
FAIL
FAIL
FAIL
FAIL
FAIL
2. The format identifier ‘%i’ is also used for _____ data type.

a) char

b) int

c) float

d) double

View Answer

Answer: b

Explanation: Both %d and %i can be used as a format identifier for int data type.

4. Which of the following is a User-defined data type?

a) typedef int Boolean;

b) typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;

c) struct {char name[10], int age};

d) all of the mentioned

View Answer

Answer: d

Explanation: typedef and struct are used to define user-defined data types.

8. What is short int in C programming?

a) The basic data type of C

b) Qualifier

c) Short is the qualifier and int is the basic data type

d) All of the mentioned

View Answer

Answer: c

Explanation: None
4. Which is correct with respect to the size of the data types?

a) char > int > float

b) int > char > float

c) char < int < double

d) double > char > int

View Answer

Answer: c

Explanation: char has less bytes than int and int has less bytes than double in any system

6. What will be the output of the following C code?

#include <stdio.h>

int main()

float x = 'a';

printf("%f", x);

return 0;

a) a

b) run time error

c) a.0000000

d) 97.000000

View Answer

Answer: d

Explanation: Since the ASCII value of a is 97, the same is assigned to the float variable and printed.

Output:

$ cc pgm8.c
$ a.out

97.000000
7. Which of the data types has the size that is variable?

a) int

b) struct

c) float

d) double

View Answer

Answer: b

Explanation: Since the size of the structure depends on its fields, it has a variable size.

1. What will be the output of the following C code?

#include <stdio.h>

int main()

enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};

printf("PEACH = %d\n", PEACH);

a) PEACH = 3

b) PEACH = 4

c) PEACH = 5

d) PEACH = 6

View Answer

Answer: c

Explanation: In enum, the value of constant is defined to the recent assignment from left.

Output:

$ cc pgm1.c

$ a.out
PEACH = 5

1. enum types are processed by _________

a) Compiler

b) Preprocessor

c) Linker

d) Assembler

View Answer

Answer: a

Explanation: None.

. Which of the following statement is false?

a) Constant variables need not be defined as they are declared and can be defined later

b) Global constant variables are initialized to zero

c) const keyword is used to define constant values

d) You cannot reassign a value to a constant variable

View Answer

Answer: a

Explanation: Since the constant variable has to be declared and defined at the same time, not doing it
results in an error.

2. Which keyword is used to prevent any changes in the variable within a C program?

a) immutable

b) mutable

c) const

d) volatile

View Answer
Answer: c

Explanation: const is a keyword constant in C program

3. Which of the following is not a pointer declaration?

a) char a[10];

b) char a[] = {‘1’, ‘2’, ‘3’, ‘4’};

c) char *str;

d) char a;

View Answer

Answer: d

Explanation: Array declarations are pointer declarations

6. A variable declared in a function can be used in main().

a) True

b) False

c) True if it is declared static

d) None of the mentioned

View Answer

Answer: b

Explanation: Since the scope of the variable declared within a function is restricted only within that
function, so the above statement is false.

4. Which of the following data type will throw an error on modulus operation(%)?

a) char

b) short

c) int

d) float

View Answer
Answer: d

Explanation: None.

1. Are logical operator sequence points?

a) True

b) False

c) Depends on the compiler

d) Depends on the standard

View Answer

Answer: a

Explanation: None.

1. function tolower(c) defined in library <ctype.h> works for ___________

a) Ascii character set

b) Unicode character set

c) Ascii and utf-8 but not EBCDIC character set

d) Any character set

View Answer

Answer: d

Explanation: None.

3. Which type of conversion is NOT accepted?

a) From char to int

b) From float to char pointer

c) From negative int to char

d) From double to char

View Answer

Answer: b

Explanation: Conversion of a float to pointer type is not allowed.


4. What will be the data type of the result of the following operation?

(float)a * (int)b / (long)c * (double)d

a) int

b) long

c) float

d) double

View Answer

Answer: d

Explanation: None.

5. Which of the following type-casting have chances for wrap around?

a) From int to float

b) From int to char

c) From char to short

d) From char to int

View Answer

Answer: b

Explanation: None.

6. Which of the following typecasting is accepted by C?

a) Widening conversions

b) Narrowing conversions

c) Widening & Narrowing conversions

d) None of the mentioned

View Answer

Answer: c

Explanation: None
7. When do you need to use type-conversions?

a) The value to be stored is beyond the max limit

b) The value to be stored is in a form not supported by that data type

c) To reduce the memory in use, relevant to the value

d) All of the mentioned

View Answer

Answer: d

Explanation: None.

2. What will be the output of the following C code?

#include <stdio.h>

int main()

int i = 10;

int *p = &i;

printf("%d\n", *p++);

a) 10

b) 11

c) Garbage value

d) Address of i

View Answer

Answer: a

Explanation: None.

Compile time error is any type of error that prevent a java program compile like a syntax
error, a class not found, a bad file name for the defined class, a possible loss of precision
when you are mixing different java data types and so on.
A runtime error means an error which happens, while the program is running. To deal with
this kind of errors java define Exceptions. Exceptions are objects represents an abnormal
condition in the flow of the program. It can be either checked or unchecked.

4. What will be the output of the following C code snippet?

#include <stdio.h>

void main()

1 < 2 ? return 1: return 2;

a) returns 1

b) returns 2

c) Varies

d) Compile time error

View Answer

Answer: d

Explanation: None.

4. What will be the final value of c in the following C statement? (Initial value: c = 2)

c <<= 1;

a) c = 1;

b) c = 2;

c) c = 3;

d) c = 4;

View Answer

Answer: d
Explanation: None.

5. What will be the output of the following C code?

#include <stdio.h>

int main()

int a = 1, b = 2;

a += b -= a;

printf("%d %d", a, b);

a) 1 1

b) 1 2

c) 2 1

d) 2 2

View Answer

Answer: c

Explanation: None.

7. Which of the following is an invalid assignment operator?

a) a %= 10;

b) a /= 10;

c) a |= 10;

d) None of the mentioned

View Answer

Answer: d

Explanation: None.
6. What will be the output of the following C code?

#include <stdio.h>

void main()

int k = 8;

int m = 7;

int z = k < m ? k++ : m++;

printf("%d", z);

a) 7

b) 8

c) Run time error

d) 15

View Answer

Answer: a

Explanation: None.

5. Which expression has to be present in the following?

exp1 ? exp2 : exp3;

a) exp1

b) exp2

c) exp3

d) all of the mentioned

View Answer

Answer: d
Explanation: None.

6. What will be the final value of c in the following C code snippet? (Initial values: a = 1, b = 2, c = 1)

c += (-c) ? a : b;

a) Syntax Error

b) c = 1

c) c = 2

d) c = 3

View Answer

Answer: c

Explanation: None.

1. Which of the following operators has an associativity from Right to Left?

a) <=

b) <<

c) ==

d) +=

View Answer

Answer: d

Explanation: None.

7. Which of the following is the correct order of evaluation for the given expression?

a = w % x / y * z;

a) % / * =

b) / * % =

c) = % * /

d) * % / =

View Answer
Answer: a

Explanation: None.

8. Which function in the following expression will be called first?

a = func3(6) - func2(4, 5) / func1(1, 2, 3);

a) func1();

b) func2();

c) func3();

d) Cannot be predicted

View Answer

Answer: d

Explanation: None.

10. Which of the following is a ternary operator?

a) &&

b) >>=

c) ?:

d) ->

View Answer

Answer: c

Explanation: None.

1. Which of the following are unary operators?


a) sizeof
b) –
c) ++
d) all of the mentioned
View Answer
Answer: d
Explanation: None.
We should know:

**Unary operators in C/C++

Unary operator: are operators that act upon a single operand to produce a new value.

Types of unary operators:

unary minus(-)

increment(++)

decrement(- -)

NOT(!)

Addressof operator(&)

sizeof()

** The sizeof operator is the most common operator in C. It is a compile-time


unary operator and used to compute the size of its operand. It returns the size of a variable. ...
When sizeof() is used with the data types, it simply returns the amount of memory allocated to
that data type.

The ternary operator take three arguments:

Ternary operator is a logical operator

The first is a comparison argument

The second is the result upon a true comparison

The third is the result upon a false comparison


2. Where in C the order of precedence of operators do not exist?

a) Within conditional statements, if, else

b) Within while, do-while

c) Within a macro definition

d) None of the mentioned

View Answer

Answer: d

Explanation: None.

3. Associativity of an operator is ___________

a) Right to Left

b) Left to Right

c) Random fashion

d) Both Right to Left and Left to Right

View Answer

Answer: d

Explanation: None.

4. Which of the following method is accepted for assignment?

a) 5 = a = b = c = d;

b) a = b = c = d = 5;

c) a = b = 5 = c = d;

d) None of the mentioned

View Answer

Answer: b

Explanation: None.

5. Which of the following is NOT possible with any 2 operators in C?


a) Different precedence, same associativity

b) Different precedence, different associativity

c) Same precedence, different associativity

d) All of the mentioned

View Answer

Answer: c

Explanation: None.

**Associativity: It defines the order in which operators of the same precedence are evaluated
in an expression. Associativity can be either from left to right or right to left. ... In C, each
operator has a fixed priority or precedence in relation to other operators.

7. Which of the following operators has the lowest precedence?

a) !=

b) &&

c) ?:

d) ,

View Answer

Answer: d

Explanation: None.

**Must know:
Here, operators with the highest precedence appear at the top of the table, those with
the lowest appear at the bottom. Within an expression, higher precedence operators will
be evaluated first.
Category Operator Associativity

Postfix () [] -> . ++ - - Left to right

Unary + - ! ~ ++ - - (type)* & sizeof Right to left

Multiplicative */% Left to right

Additive +- Left to right

Shift << >> Left to right

Relational < <= > >= Left to right

Equality == != Left to right

Bitwise AND & Left to right

Bitwise XOR ^ Left to right

Bitwise OR | Left to right

Logical AND && Left to right

Logical OR || Left to right

Conditional ?: Right to left

Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left


Comma , Left to right

3. What will be the output of the following C code?

#include <stdio.h>

void main()

int x = 5;

if (true);

printf("hello");

a) It will display hello

b) It will throw an error

c) Nothing will be displayed

d) Compiler dependent

View Answer

Answer: b

Explanation: None.

4. What will be the output of the following C code?

#include <stdio.h>

void main()

int x = 0;

if (x == 0)

printf("hi");
else

printf("how are u");

printf("hello");

a) hi

b) how are you

c) hello

d) hihello

5. What will be the output of the following C code?

#include <stdio.h>

void main()

int x = 5;

if (x < 1); // empty statement do nothing

printf("Hello");

a) Nothing

b) Run time error

c) Hello

d) Varies

View Answer

Answer: c

Explanation: An empty statement do nothing

7. Which of the following is an invalid if-else statement?

a) if (if (a == 1)){}
b) if (func1 (a)){}

c) if (a){}

d) if ((char) a){}

View Answer

Answer: a

Explanation: None.

1. Which keyword can be used for coming out of recursion?

a) break

b) return

c) exit

d) both break and return

View Answer

Answer: b

Explanation: None.

5. Which keyword is used to come out of a loop only for that iteration?

a) break

b) continue

c) return

d) none of the mentioned

View Answer

Answer: b

Explanation: None.
6. What will be the output of the following C code?

#include <stdio.h>

void main()

int i = 0, j = 0;

for (i = 0;i < 5; i++)

for (j = 0;j < 4; j++)

if (i > 1)

break;

printf("Hi \n");

a) Hi is printed 5 times

b) Hi is printed 9 times

c) Hi is printed 7 times

d) Hi is printed 4 times

View Answer

Answer: a

Explanation: None.

The continue statement in C programming works somewhat like the break statement.
Instead of forcing termination, it forces the next iteration of the loop to take place,
skipping any code in between.
For the for loop, continue statement causes the conditional test and increment portions
of the loop to execute. For the while and do...while loops, continue statement causes
the program control to pass to the conditional tests.

The break statement in C programming has the following two usages − When
a break statement is encountered inside a loop, the loop is immediately terminated and
the program control resumes at the next statement following the loop. It can be used to
terminate a case in the switch statement (covered in the next chapter).

3. Operation “a = a * b + a” can also be written as ___________

a) a *= b + 1;

b) (c = a * b)!=(a = c + a);

c) a = (b + 1)* a;

d) All of the mentioned

View Answer

Answer: d

Explanation: None.

IndiaBIX.Com

Search...

MenuHomeAptitudeLogicalVerbalCurrent AffairsGKEngineeringInterviewOnline
TestsPuzzles

Database :: The Relational Model and Normalization

Home » Engineering » Database » The Relational Model and Normalization » General


Questions
Exercise :: The Relational Model and Normalization - General Questions

The Relational Model and Normalization - General Questions

The Relational Model and Normalization - True or False

1.

Every time attribute A appears, it is matched with the same value of attribute B, but not
the same value of attribute C. Therefore, it is true that:

A. A → B.

B. A → C.

C. A → (B,C).

D. (B,C) → A.

Answer: Option A

This set of Data Structure Interview Questions and Answers focuses on “Stack
Operations – 2”.

1. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

a) AB+ CD*E – FG /**

b) AB + CD* E – F **G /

c) AB + CD* E – *F *G /

d) AB + CDE * – * F *G /

View Answer

Answer: c

Explanation: (((A+ B)*(C*D- E)*F) / G) is converted to postfix expression as


(AB+(*(C*D- E)*F )/ G)

(AB+CD*E-*F) / G

(AB+CD*E-*F * G/). Thus Postfix expression is AB+CD*E-*F*G/

5. The postfix form of A*B+C/D is?

a) *AB/CD+

b) AB*CD/+

c) A*BC+/D

d) ABCD+/*

View Answer

Answer: b

Explanation: Infix expression is (A*B)+(C/D)

AB*+(C/D)

AB*CD/+. Thus postfix expression is AB*CD

6. Which data structure is needed to convert infix notation to postfix notation?

a) Branch

b) Tree

c) Queue

d) Stack

View Answer
Answer: d

Explanation: The Stack data structure is used to convert infix expression to postfix
expression. The purpose of stack is to reverse the order of the operators in the
expression. It also serves as a storage structure, as no operator can be printed until both
of its operands have appeared.

7. The prefix form of A-B/ (C * D ^ E) is?

a) -/*^ACBDE

b) -ABCD*^DE

c) -A/B*C^DE

d) -A/BC*^DE

View Answer

Answer: c

Explanation: Infix Expression is (A-B)/(C*D^E)

(-A/B)(C*D^E)

-A/B*C^DE. Thus prefix expression is -A/B*C^DE


1. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

a) 600

b) 350

c) 650

d) 588

View Answer

Answer: b

Explanation: The postfix expression is evaluated using stack. We will get the infix expression as

(5*(4+6))*(4+9/3). On solving the Infix Expression, we get

(5*(10))*(4+3)
= 50*7

= 350.

6. Which of the following is not an inherent application of stack?

a) Reversing a string

b) Evaluation of postfix expression

c) Implementation of recursion

d) Job scheduling

View Answer

Answer: d

Explanation: Job Scheduling is not performed using stacks.

7. The type of expression in which operator succeeds its operands is?

a) Infix Expression

b) Prefix Expression

c) Postfix Expression

d) Both Prefix and Postfix Expressions

View Answer

Answer: c

Explanation: The expression in which operator succeeds its operands is called postfix expression. The
expression in which operator precedes the operands is called prefix expression. If an operator is present
between two operands, then it is called infix expressions.

9. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the
order of removal?

a) ABCD

b) DCBA

c) DCAB

d) ABDC

View Answer
Answer: b

Explanation: Stack follows LIFO(Last In First Out). So the removal order of elements are DCBA.

2. The data structure required for Breadth First Traversal on a graph is?

a) Stack

b) Array

c) Queue

d) Tree

View Answer

Answer: c

Explanation: In Breadth First Search Traversal, BFS, starting vertex is first taken and adjacent vertices
which are unvisited are also taken. Again, the first vertex which was added as an unvisited adjacent
vertex list will be considered to add further unvisited vertices of the graph. To get first unvisited vertex
we need to follows First In First Out principle. Queue uses FIFO principle.

5. What would be the asymptotic time complexity to insert an element at the front of the linked list
(head is known)?

a) O(1)

b) O(n)

c) O(n2)

d) O(n3)

View Answer

Answer: b

Explanation: To add an element at the front of the linked list, we will create a new node which holds the
data to be added to the linked list and pointer which points to head position in the linked list. The entire
thing happens within O (1) time. Thus the asymptotic time complexity is O (1).

You might also like