Skip to content

Instantly share code, notes, and snippets.

@ahmedahamid
ahmedahamid / binary_search_iterative.cpp
Last active September 20, 2015 05:35
Tricky pointer basics explained | Iterative implementation of binary search
tree_node* binary_search(tree_node* n, int value)
{
if (n == NULL)
{
return NULL;
}
tree_node* x = n;
while (x != NULL)
@ahmedahamid
ahmedahamid / binary_search_recursive.cpp
Last active September 20, 2015 05:10
Tricky pointer basics explained | Recursive implementation of binary search
tree_node* binary_search(tree_node* n, int value)
{
if (n == NULL)
{
return NULL;
}
if (value == n->data)
{
return n;
@ahmedahamid
ahmedahamid / C++Example.cpp
Last active May 10, 2016 02:57
Why I started to feel differently about C# | Using STL map
//
// (1) C++: - Defining a dictionary [key type=string, value type=int]
// - No easy way to initialize.
//
map<string, int> dict;
//
// (1`) C++11: Defining and initializing a dictionary [key type=string, value type=int]
//
map<string, int> dict
{
@ahmedahamid
ahmedahamid / C#Example.cs
Last active May 10, 2016 02:58
Why I started to feel differently about C# | Using Dictionaries
//
// (1) C#: Defining an initializing a dictionary [key type=string, value type=int]
//
Dictionary<string, int> dict = new Dictionary<string, int>()
{
{"Eve", 101},
{"George", 150},
{"Emma", 200}
};
//