Skip to content

Ericsson C Programming with DSA Interview Questions & Answers

Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.

About Ericsson hiring for C Programming with DSA roles

Ericsson is a Swedish telecommunications company that provides network equipment, software and services for mobile operators, including 4G and 5G radio, core networks and network management. In India it supports major telecom operators with network deployment and managed services, and runs research and development centres. It hires telecom engineers, software engineers, testers and network engineers.

For C Programming with DSA roles, this Ericsson practice set focuses most on C Basics, Data Types and Operators (7), Arrays and Strings (5), Linked Lists (4), Structures, Unions and File Handling (4). It has 14 easy, 15 medium, 1 hard questions, so you can start easy and work up to the harder ones.

Company type
Telecom
Headquarters
Stockholm, Sweden
Main India offices
Gurugram, Bengaluru, Chennai, Noida, Kolkata

Ericsson C Programming with DSA interview process

  1. Online assessment (aptitude + technical)
  2. Technical interview
  3. Managerial round
  4. HR round

Typical pattern based on public candidate experiences. Rounds vary by role, team and year.

Solved for EricssonStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

How do you convert an infix expression to postfix?

Save to ▾
Show answer
Use the shunting yard algorithm with an operator stack. Output operands directly. For an operator, pop operators of higher precedence, or equal precedence if left associative, to the output, then push it. Push '(' and on ')' pop until the matching '('. At the end, pop all remaining operators. For example a + b * c becomes a b c * +. Postfix is easy to evaluate with a stack.
02

What are the types of linked lists?

Save to ▾
Show answer
A singly linked list has a next pointer only and can be traversed one way. A doubly linked list adds a prev pointer, allowing backward traversal and O(1) deletion of a known node, at the cost of more memory. A circular linked list links the last node back to the first, useful for round-robin scheduling. Variants include lists with sentinel or dummy head nodes.
03

Rotate an array to the right by k positions in O(n) time and O(1) space.

Save to ▾
Show answer
Use three reversals. void rev(int *a, int l, int r) { while (l < r) { int t = a[l]; a[l++] = a[r]; a[r--] = t; } } void rotate(int *a, int n, int k) { k %= n; if (k == 0) return; rev(a, 0, n - 1); rev(a, 0, k - 1); rev(a, k, n - 1); } For 1 2 3 4 5 with k = 2 the result is 4 5 1 2 3.
04
Save to ▾
Show answer
Big O describes how an algorithm's time or memory grows as input size grows, ignoring constants and lower terms. Common classes are O(1), O(log n), O(n), O(n log n), O(n squared) and O(2 to the n). It usually describes the worst case. For example, binary search is O(log n), so a million elements need about 20 steps. Big Omega and Big Theta describe lower and tight bounds.
05

Allocate and free a dynamic 2D array of rows by cols in C.

Save to ▾
Show answer
A single block is cache friendly and easy to free. int (*grid)[cols] = malloc(rows * sizeof *grid); if (!grid) return -1; grid[2][3] = 5; free(grid); // array of row pointers alternative int **m = malloc(rows * sizeof *m); for (int i = 0; i < rows; i++) m[i] = calloc(cols, sizeof **m); for (int i = 0; i < rows; i++) free(m[i]); free(m); The first form uses a variable length array type.
06

What are the basic data types in C and their typical sizes?

Save to ▾
Show answer
C has char (1 byte), short (usually 2), int (usually 4), long (4 on Windows, 8 on 64-bit Linux), long long (at least 8), float (4) and double (8). The standard only fixes minimum ranges, so sizes depend on the platform. Use sizeof to check and the fixed-width types from stdint.h such as int32_t and uint8_t when exact sizes matter.
07

What is the difference between malloc, calloc, realloc and free?

Save to ▾
Show answer
malloc(size) allocates uninitialised memory. calloc(n, size) allocates memory for n elements and sets all bytes to zero, and it checks n times size for overflow. realloc(ptr, size) resizes a block, possibly moving it, and returns the new address. free(ptr) releases memory back to the allocator. All allocators return NULL on failure, so always check the result.
08

Write a header guard and explain why it is needed.

Save to ▾
Show answer
A header guard stops a header from being included twice in one translation unit, which would cause redefinition errors. #ifndef MATH_UTILS_H #define MATH_UTILS_H int add(int a, int b); #endif Most compilers also support #pragma once, which is shorter but not part of the C standard.
09

What is a trie and when is it better than a hash table?

Save to ▾
Show answer
A trie is a tree where each edge represents a character, so words sharing a prefix share a path. Lookup and insert take O(L) for a word of length L, independent of how many words are stored. It beats a hash table for prefix queries such as autocomplete, spell checking and longest prefix matching in IP routing. The trade-off is higher memory use from many child pointers.
10

How do you set, clear and toggle a particular bit in C?

Save to ▾
Show answer
Use bit masks with shift operators. x |= (1u << n); // set bit n x &= ~(1u << n); // clear bit n x ^= (1u << n); // toggle bit n int bit = (x >> n) & 1u; // read bit n Use unsigned types so shifts are well defined. These operations are common in embedded code for configuring hardware registers.
11

How would you check whether a binary tree is a valid BST?

Save to ▾
Show answer
Comparing each node only with its children is wrong, because a deeper node can break the rule. Pass a valid range down: the left child must be in (min, node value) and the right child in (node value, max), starting with the full range of long long. Alternatively, do an in-order traversal and check values are strictly increasing. Both are O(n).
12

Write Kadane's algorithm in C.

Save to ▾
Show answer
Track the best sum ending here and the overall best. long maxSubarray(const int *a, int n) { long cur = a[0], best = a[0]; for (int i = 1; i < n; i++) { cur = (cur + a[i] > a[i]) ? cur + a[i] : a[i]; if (cur > best) best = cur; } return best; } Input {-2, 1, -3, 4, -1, 2, 1, -5, 4} returns 6 for subarray 4, -1, 2, 1.
13

How does Floyd's cycle detection algorithm work?

Save to ▾
Show answer
Use a slow pointer moving one step and a fast pointer moving two steps. If the list has a cycle, the fast pointer eventually meets the slow one inside the loop; if fast reaches NULL, there is no cycle. To find the cycle start, reset one pointer to head and move both one step at a time; they meet at the start. It uses O(n) time and O(1) space.
14

Why is a dummy or sentinel node useful in linked list code?

Save to ▾
Show answer
A dummy node placed before the real head removes special cases for an empty list or for inserting and deleting at the head, because every real node then has a previous node. Code for merging lists, removing elements and partitioning becomes shorter and less error prone. At the end, return dummy.next as the new head. It costs one extra node.
15

Write binary search in C that returns the index of the target or -1.

Save to ▾
Show answer
Use an overflow safe midpoint. int binarySearch(const int *a, int n, int target) { int lo = 0, hi = n - 1; while (lo <= hi) { int mid = lo + (hi - lo) / 2; if (a[mid] == target) return mid; if (a[mid] < target) lo = mid + 1; else hi = mid - 1; } return -1; } Time O(log n). The array must be sorted in ascending order.
16

Explain the tree traversal orders.

Save to ▾
Show answer
In-order visits left, node, right and gives sorted output for a BST. Pre-order visits node, left, right and is used to copy or serialise a tree. Post-order visits left, right, node and is used to delete a tree or evaluate expression trees. Level-order visits nodes level by level using a queue. The first three are depth first and use recursion or an explicit stack.
17

A function returns the address of a local array and the caller gets wrong data. Why?

Save to ▾
Show answer
Local arrays live on the stack and are destroyed when the function returns, so the returned pointer is dangling and later calls overwrite that memory. Fix it by having the caller pass a buffer and its size, allocating with malloc and documenting that the caller must free it, or using a static buffer, which is not thread safe. Compilers warn about this with -Wreturn-local-addr.
18

What is the difference between char s[] = "hello" and char *s = "hello"?

Save to ▾
Show answer
char s[] = "hello" creates a modifiable array of 6 bytes, usually on the stack, initialised with a copy of the literal. char *s = "hello" makes a pointer to a string literal stored in read-only memory; modifying it is undefined behaviour and often crashes. Declare such pointers as const char * so the compiler catches accidental writes.
19

Write a C function to count words in a sentence.

Save to ▾
Show answer
Count transitions from space to non-space. #include <ctype.h> int countWords(const char *s) { int count = 0, inWord = 0; for (; *s; s++) { if (isspace((unsigned char)*s)) { inWord = 0; } else if (!inWord) { inWord = 1; count++; } } return count; } This handles multiple spaces, tabs and leading or trailing spaces correctly.
20

What is the time complexity of common linked list operations?

Save to ▾
Show answer
Access or search by value is O(n). Insert or delete at the head is O(1). Insert at the tail is O(1) if you keep a tail pointer, otherwise O(n). Deleting a given node is O(1) in a doubly linked list but O(n) in a singly linked list, since you must find the previous node. Finding length is O(n) unless you store a count.
21

A program that writes logs with fprintf loses the last lines when it crashes. Why, and how do you fix it?

Save to ▾
Show answer
stdio streams are buffered, so fprintf stores data in memory and writes it to disk only when the buffer fills, the file closes or fflush is called. A crash loses whatever is still in the buffer. Call fflush after important log lines, set line buffering with setvbuf(fp, NULL, _IOLBF, 0) or write critical messages to unbuffered stderr. For durability on disk, add fsync on POSIX systems.
22

What is a monotonic stack?

Save to ▾
Show answer
A monotonic stack keeps elements in increasing or decreasing order by popping elements that break the order before pushing a new one. Each element is pushed and popped at most once, so problems run in O(n). It solves next greater element, daily temperatures, stock span and largest rectangle in a histogram, which would otherwise need nested loops.
23

What is the difference between a macro and an inline function?

Save to ▾
Show answer
A macro is plain text substitution by the preprocessor, with no type checking, and arguments may be evaluated more than once, so SQUARE(i++) misbehaves. An inline function is a real function with type checks and single evaluation of arguments, which the compiler may expand in place for speed. Prefer static inline functions and use macros only for things like conditional compilation.
24

Your embedded device must store 10,000 sensor records in limited RAM. How would you design the struct?

Save to ▾
Show answer
Use fixed-width types sized to the real range, such as uint16_t for readings and uint32_t for timestamps, order members from largest to smallest to cut padding and pack boolean flags into bit fields or a single bitmask byte. Consider storing time as an offset from a base to save bytes. Check sizeof in a static assertion so the size stays as designed.
25

Write a C function to check whether a number is an Armstrong number.

Save to ▾
Show answer
Sum of digits raised to the number of digits equals the number. int isArmstrong(int n) { int digits = 0, t = n, sum = 0; while (t) { digits++; t /= 10; } t = n; while (t) { int d = t % 10, p = 1; for (int i = 0; i < digits; i++) p *= d; sum += p; t /= 10; } return sum == n; } For example 153 = 1 + 125 + 27.
26

What is the difference between ++i and i++?

Save to ▾
Show answer
++i increments i and then yields the new value, while i++ yields the old value and then increments. As a standalone statement both have the same effect, and modern compilers generate the same code. The difference matters inside expressions: if i is 5, a = i++ sets a to 5, while a = ++i sets a to 6. Never use both on the same variable in one expression.
27

Explain storage classes in C.

Save to ▾
Show answer
auto is the default for local variables, stored on the stack with block lifetime. register hints the variable should live in a CPU register, and its address cannot be taken. static gives a local variable lifetime for the whole program, or limits a global to its file. extern declares a variable defined in another file. Storage class decides scope, lifetime and linkage.
28

A file opened with fopen is NULL in production but fine on your machine. How do you debug?

Save to ▾
Show answer
Always check the return value and print the reason with perror or strerror(errno), which shows errors like No such file or directory or Permission denied. Common causes are a relative path resolved from a different working directory, missing permissions for the service user, a full disk or too many open files. Use absolute or configured paths and close every file you open.
29

What is typedef and how is it used with structures?

Save to ▾
Show answer
typedef creates an alias for a type. typedef struct Node { int data; struct Node *next; } Node; lets you write Node *head instead of struct Node *head. It is also useful for function pointer types and platform specific types. Some style guides avoid hiding pointers behind typedefs because it makes ownership and const usage less clear.
30

What is a prefix sum array and why is it useful?

Save to ▾
Show answer
A prefix sum array stores pre[i] = sum of elements from index 0 to i-1. Then the sum of any range from l to r is pre[r + 1] - pre[l] in O(1) after O(n) preprocessing. It is used for range sum queries, counting subarrays with a given sum together with a hash map, and 2D versions for matrix region sums.

Tips to crack the Ericsson C Programming with DSA interview

  • Revise computer networks, TCP/IP, and basics of mobile communication such as LTE and 5G architecture before interviews.
  • Practise programming in C, C++, Java or Python, and be ready to solve simple coding and debugging problems.
  • Learn about Ericsson's role in 5G rollouts in India to discuss the industry and your interest in telecom.
  • Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
  • Practise the hard questions on this page aloud; Ericsson interviewers usually ask follow-ups on your first answer.

Frequently asked questions

How many rounds are there in the Ericsson C Programming with DSA interview?

Candidates usually go through 4 stages: Online assessment (aptitude + technical); Technical interview; Managerial round; HR round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.

Which topics should I prepare for the Ericsson C Programming with DSA interview?

This practice set leans on C Basics, Data Types and Operators (7), Arrays and Strings (5), Linked Lists (4), Structures, Unions and File Handling (4). Revise those first, then practise explaining one or two of your own projects end to end, because most Ericsson interviewers ask you to walk through real work.

Are these the exact questions asked at Ericsson?

No. These are curated practice questions that match the skills and difficulty usually tested in telecom interviews like Ericsson's. They are not a leaked or verified list of past questions.

Where does Ericsson hire C Programming with DSA professionals in India?

Ericsson has large teams in Gurugram, Bengaluru, Chennai, Noida, Kolkata. Openings and locations change often, so check the Ericsson careers page and filter by city and experience.

C Programming with DSA questions for similar companies