Skip to content

Instantly share code, notes, and snippets.

@d2idan
d2idan / sequence.c
Last active December 18, 2016 19:36
function sequence. INPUT:linked list of numbers; OUTPUT:size of a new linked list . if the list had a sequence of equal number and if the length of the sequence is k such that k is greater or equal to 3 then do : change the first element in the sequence to -k. delete all elements in the sequence starting from the third element in the sequence.
//running time O(n)
//in place
/**
*the idea is to draw an example and to see what's needs to be done , so the idea is to use simple logic :)
*/
#include <stdio.h>
#include <stdlib.h>
#define SIZE 16
@d2idan
d2idan / EvenBeforeOddInList.c
Last active December 18, 2016 00:17
code for changing the order in a singly linked list such that even numbers positioned before odd numbers
//running time O(n)
//in place
/**
*the idea is to move all the elements with even values to the head.
*/
#include <stdio.h>
#include <stdlib.h>
struct Node{