AMD 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 AMD hiring for C Programming with DSA roles
AMD is an American semiconductor company that designs CPUs, GPUs, adaptive chips and data centre accelerators, including Ryzen, EPYC, Radeon and Instinct products. It acquired Xilinx, adding FPGA and adaptive computing products. In India it has large design centres that hire chip design, verification, physical design, software and firmware engineers.
For C Programming with DSA roles, this AMD practice set focuses most on C Basics, Data Types and Operators (7), Sorting, Searching and Dynamic Programming (6), Arrays and Strings (4), Structures, Unions and File Handling (4). It has 2 easy, 25 medium, 3 hard questions, so you can start easy and work up to the harder ones.
Company type
Hardware & semiconductors
Headquarters
Santa Clara, California, USA
Main India offices
Bengaluru, Hyderabad
AMD C Programming with DSA interview process
Online assessment or resume screening
Technical round 1 (digital design or programming)
Technical round 2 (domain depth)
Hiring manager round
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for AMDStart 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
What is the difference between a macro and an inline function?
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.
02
A strlen call crashes on a buffer received from a network packet. What is wrong?
Network data is not guaranteed to be null terminated, so strlen keeps reading past the buffer until it hits a zero byte or invalid memory. Always track the received byte count and use length-aware functions such as memchr, strnlen or memcpy with explicit sizes. If you need a C string, allocate one extra byte and add the terminator yourself after checking the length.
03
A hash table becomes slow as more data is inserted. What is wrong?
The load factor has grown, so chains get long or open addressing probes become long, turning O(1) into nearly O(n). Another cause is a poor hash function clustering keys into few buckets. Fix it by resizing to roughly double capacity and rehashing when the load factor crosses a threshold, and by using a better hash function. Measure the longest chain to confirm.
04
How would you check whether a binary tree is a valid BST?
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).
05
Two source files both define a global variable named count and the build fails. How do you fix it?
Each global may be defined only once. Define it in one .c file, such as int count = 0;, and declare it in a shared header as extern int count;, which other files include. If the variable should be private to each file, mark it static in both files instead. Since GCC 10, -fno-common is default, so duplicate tentative definitions also fail to link.
06
A program reads a file with while (!feof(fp)) and processes the last line twice. Why?
feof() becomes true only after a read has already failed at end of file. The loop checks feof before reading, so the final failed read leaves the old buffer content, which is processed again. Loop on the read function's return value instead, such as while (fgets(line, sizeof line, fp) != NULL), and check ferror after the loop.
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.
08
Memory use of a long running C service grows every hour. How do you investigate?
Run it under Valgrind or with AddressSanitizer and LeakSanitizer in a test environment and reproduce typical traffic, then read the leak report with allocation stack traces. In production, compare heap usage over time with tools like heaptrack. Check error paths that return early without free, lost pointers after realloc, and caches without size limits. Fix ownership and add a leak check to CI.
09
A linked list used in a multithreaded C server sometimes corrupts. How would you fix it?
Concurrent inserts and deletes race on next pointers. The simplest fix is a pthread mutex around every list operation, keeping critical sections short. For read-heavy workloads, a read-write lock lets readers run in parallel. Lock-free lists with atomic compare-and-swap are possible but very hard to get right because of the ABA problem and safe memory reclamation, so use them only with proven libraries.
10
A loop that sums large numbers gives a negative result. What is happening?
The sum overflowed the range of int, and signed overflow in C is undefined behaviour, often wrapping to a negative value. Use a wider type like long long or int64_t for the accumulator, check before adding with a condition like if (sum > INT_MAX - x), or use compiler builtins such as __builtin_add_overflow. Compile with -fsanitize=undefined to catch it during testing.
11
Write C code to count the number of set bits in an integer.
Brian Kernighan's trick clears the lowest set bit each step.
int countBits(unsigned int n) {
int count = 0;
while (n) {
n &= n - 1;
count++;
}
return count;
}
It runs once per set bit. GCC and Clang also offer __builtin_popcount(n), which uses a CPU instruction when available.
12
Merge two sorted linked lists into one sorted list.
Local automatic variables are not initialised in C, so they hold whatever bytes were on the stack. Reading them is undefined behaviour and gives random results. Initialise every variable at declaration, such as int sum = 0;. Compiling with -Wall -Wuninitialized and running under Valgrind or with -fsanitize=memory helps detect such reads early.
14
An interview asks for the minimum number of coins to make an amount. How do you approach it?
Greedy fails for some coin sets, such as coins 1, 3, 4 with amount 6, where greedy gives three coins but two coins of 3 is optimal. Use DP: dp[0] = 0 and dp[x] = 1 + min over coins c of dp[x - c], filling from 1 to the amount. Time is O(amount times coins) and space O(amount). Report -1 if the amount cannot be formed.
15
You must schedule the maximum number of non-overlapping meetings in one room. What algorithm do you use?
This is activity selection, solved greedily. Sort meetings by end time, then pick each meeting whose start is not earlier than the end of the last picked one. Choosing the earliest finishing meeting always leaves the most room for the rest, which can be proven by an exchange argument. Sorting dominates, giving O(n log n) time.
Partition around the last element, then sort both sides.
void swap(int *x, int *y) { int t = *x; *x = *y; *y = t; }
int partition(int *a, int lo, int hi) {
int pivot = a[hi], i = lo;
for (int j = lo; j < hi; j++)
if (a[j] < pivot) swap(&a[i++], &a[j]);
swap(&a[i], &a[hi]);
return i;
}
void quickSort(int *a, int lo, int hi) {
if (lo < hi) {
int p = partition(a, lo, hi);
quickSort(a, lo, p - 1);
quickSort(a, p + 1, hi);
}
}
Sliding window solves problems on contiguous subarrays or substrings by keeping a window with two indexes and moving them forward instead of rechecking every subarray. A fixed window finds things like the maximum sum of k elements, while a variable window expands and shrinks, as in the longest substring without repeating characters. It turns O(n squared) brute force into O(n).
From low to high address, a typical process has the text segment holding code, the initialised data segment for globals and statics with values, BSS for uninitialised or zero globals, the heap growing upward for malloc memory, and the stack growing downward for function frames and local variables. Knowing this helps explain stack overflow, memory leaks and where variables live.
19
Your program sorts 1 crore integers in the range 0 to 999 and qsort is too slow. What would you do?
With a small known range, use counting sort: count occurrences in an array of 1000 counters, then rewrite the array in order. It runs in O(n + k) time with only 1000 extra integers, far faster than O(n log n) comparison sorts. For larger ranges, radix sort on bytes works well. qsort also pays a function call per comparison through its comparator pointer.
20
Use qsort with a function pointer to sort an array of integers in descending order.
Write a comparator that returns negative, zero or positive.
int cmpDesc(const void *a, const void *b) {
int x = *(const int *)a;
int y = *(const int *)b;
return (y > x) - (y < x);
}
int arr[] = {4, 1, 9, 3};
qsort(arr, 4, sizeof arr[0], cmpDesc);
Returning y - x can overflow, so the comparison form is safer.
21
Use a tagged union to store either an int, a float or a string value.
strcpy copies until the null terminator with no bounds check, so it can overflow. strncpy limits the count but does not add a terminator if the source is too long and pads with zeros otherwise, which surprises many developers. snprintf(dst, size, "%s", src) always terminates and returns the length it wanted, so you can detect truncation. Prefer snprintf or a checked helper.
The master theorem gives the time complexity of divide and conquer recurrences of the form T(n) = aT(n/b) + f(n). Compare f(n) with n to the power log base b of a. For merge sort, a = 2, b = 2 and f(n) = n, which match, giving O(n log n). For binary search, a = 1 and b = 2 with constant work, giving O(log n). It does not cover every recurrence.
24
How do you check whether a linked list is a palindrome in O(1) extra space?
Find the middle with slow and fast pointers, reverse the second half in place, then compare the first half and the reversed second half node by node. Finally reverse the second half again to restore the list, which interviewers appreciate. Time is O(n) and extra space is O(1). A simpler O(n) space approach copies values into an array or stack first.
25
A program that writes logs with fprintf loses the last lines when it crashes. Why, and how do you fix it?
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.
26
Find the length of the longest substring without repeating characters in C.
Sliding window with last seen positions.
int longestUnique(const char *s) {
int last[256];
for (int i = 0; i < 256; i++) last[i] = -1;
int best = 0, start = 0;
for (int i = 0; s[i]; i++) {
unsigned char c = s[i];
if (last[c] >= start) start = last[c] + 1;
last[c] = i;
if (i - start + 1 > best) best = i - start + 1;
}
return best;
}
For abcabcbb it returns 3.
27
What is the difference between greedy algorithms and dynamic programming?
A greedy algorithm makes the best local choice at each step and never revisits it, which works only when the greedy choice property holds, as in activity selection, Huffman coding and Dijkstra. Dynamic programming considers all relevant subproblem choices and combines them, so it works where greedy fails, such as 0/1 knapsack or coin change with arbitrary denominations. Greedy is faster when provably correct.
28
Write code to check whether the machine is little endian or big endian.
Look at the first byte of a known integer.
int isLittleEndian(void) {
uint32_t x = 1;
unsigned char *p = (unsigned char *)&x;
return p[0] == 1;
}
// using a union
union { uint32_t i; unsigned char c[4]; } u = { 1 };
int little = (u.c[0] == 1);
x86 and most ARM systems are little endian; network byte order is big endian.
29
Write BFS on a graph stored as an adjacency matrix.
Use a queue and a visited array.
void bfs(int n, int adj[n][n], int start) {
int visited[n], queue[n], front = 0, rear = 0;
for (int i = 0; i < n; i++) visited[i] = 0;
visited[start] = 1;
queue[rear++] = start;
while (front < rear) {
int u = queue[front++];
printf("%d ", u);
for (int v = 0; v < n; v++) {
if (adj[u][v] && !visited[v]) {
visited[v] = 1;
queue[rear++] = v;
}
}
}
}
30
Write a header guard and explain why it is needed.
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.
Tips to crack the AMD C Programming with DSA interview
Revise digital electronics, computer architecture, Verilog and verification basics for silicon roles, with clear explanations of timing concepts.
For software and driver roles, revise C, C++, operating systems and parallel computing basics, including GPU programming concepts.
Prepare detailed explanations of VLSI or embedded projects, including tools used, problems faced and how you solved them.
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; AMD interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the AMD C Programming with DSA interview?
Candidates usually go through 4 stages: Online assessment or resume screening; Technical round 1 (digital design or programming); Technical round 2 (domain depth); Hiring manager 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 AMD C Programming with DSA interview?
This practice set leans on C Basics, Data Types and Operators (7), Sorting, Searching and Dynamic Programming (6), Arrays and Strings (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 AMD interviewers ask you to walk through real work.
Are these the exact questions asked at AMD?
No. These are curated practice questions that match the skills and difficulty usually tested in hardware & semiconductors interviews like AMD's. They are not a leaked or verified list of past questions.
Where does AMD hire C Programming with DSA professionals in India?
AMD has large teams in Bengaluru, Hyderabad. Openings and locations change often, so check the AMD careers page and filter by city and experience.
C Programming with DSA questions for similar companies