All Questions
15 questions
8
votes
4
answers
524
views
Array List C implementation
I want to show you my implementation of the array list in C. Is there something I can improve or fix?
Header
...
2
votes
1
answer
94
views
A (Sort of) Generic Stack Implementation in C using Macros
I spent some time implementing a generic stack in C using macros. Apart from general bugs and bad practices in my code, I was wondering about the viability of an implementation like this that uses ...
0
votes
2
answers
2k
views
3
votes
1
answer
1k
views
Quicksort using Lomuto partition scheme in C
This is my implementation of the divide-and-conquer Quicksort algorithm using the Lomuto partition scheme in C. This is part of a personal project and I'm following Linus Torvalds's coding style.
<...
2
votes
3
answers
858
views
My own array implementation in C
I've been trying to remember old programming concepts like data structures.
My first challenge was about implementing my own array of positive integers:
...
3
votes
2
answers
115
views
A Stack Implementation In C
I've written a very simple linked list based stack implementation and was wondering if this is the standard way to do it in C.
...
3
votes
1
answer
148
views
Counting sort in C, revised
This is a revised follow-up to this question.
I have implemented most of the suggestions in the accepted answer. I am interested to see what I could improve in my code and what I could do to make it ...
3
votes
3
answers
2k
views
Tower Hopper problem recursive approach
The Tower Hopper problem gives us an array of values representing heights that express how far we can jump from a certain tower, and asks whether there's a way to get from ...
-2
votes
2
answers
91
views
An array adding numbers to a specified sequence
I have to make a program that modifies an array like this: it takes a sequence in an array and sums up a number to each element in the sequence and repeats this many times. The array's elements are <...
10
votes
6
answers
1k
views
Primitive String trimmer in C
I just picked up C and am following through The C programming language.
I've previously got experience with a lot of 'higher'-level languages, so when I saw this exercise in the book:
Write a ...
7
votes
1
answer
2k
views
Cipher text using a 2D array
I have a simple program which ciphers text using a 2D array. You specify what letters to replace with what and it does it.
I understand the code is very repetitive and that I should probably use ...
4
votes
1
answer
963
views
Max difference between two array elements
Can I get feedback on below code? Problem statement is Maximum difference between two elements such that larger element appears after the smaller number
Would this solution be still considered O(n) ...
2
votes
1
answer
1k
views
Find the contiguous subarray within an array (containing at least one number) which has the largest sum
Interview Q: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example: Given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [...
1
vote
1
answer
1k
views
Missing element from array (D&C) - code design/aesthetic improvement
I am trying to implement in C/C++ a 'classical' Divide and Conquer algorithm which solves the following problem "Given an array of n-1 numbers (int) from 0 to n, find the missing number".
I am using ...
4
votes
1
answer
6k
views
Quicksort using pointers
As an exercise, I've written quicksort algorithm in C using pointers. Please comment and help me find the cases where it breaks (if any).
...