Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dfs(graph, start): | |
""" | |
Perform Depth-First Search (DFS) on a graph starting from a given node. | |
Args: | |
graph: Dictionary representing the adjacency list of the graph | |
start: Starting node for DFS | |
Returns: | |
Dictionary with discovery and finish times for each node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// Define a structure for DynamicArray | |
typedef struct { | |
int *data; // Pointer to the array of elements | |
int size; // Number of elements currently in the array | |
int capacity; // Total capacity (allocated memory) of the array | |
} DynamicArray; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define LOAD_FACTOR_UPPER 1.0 | |
#define LOAD_FACTOR_LOWER 0.25 | |
#define INITIAL_CAPACITY 8 | |
// ------------------- Node & Doubly Linked List ------------------- | |
typedef struct Node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
// Fixed sizes for each data structure | |
#define STACK_SIZE 5 | |
#define QUEUE_SIZE 5 | |
#define LIST_SIZE 10 | |
// -------------------------- | |
// Stack Class Implementation |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Imagine this is loss function | |
def polynomial(w): | |
return (w**5 - 3*w**4 + 2*w**3 + w**2 - w + 1)/100000 | |
# Imagine this is loss function multiplied by 10000 | |
def scaled_polynomial(w): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MinHeap: | |
def __init__(self, data=None): | |
""" | |
Initialize a Min Heap. | |
:param data: Optional list to build the heap from. | |
""" | |
self.heap = data if data else [] | |
if data: | |
self.build_min_heap() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n, depth=0): | |
indent = " " * depth # Indentation for better visualization | |
print(f"{indent}fib({n}) called") | |
if n == 0: | |
print(f"{indent}Returning 0") | |
return 0 | |
if n == 1: | |
print(f"{indent}Returning 1") | |
return 1 |
NewerOlder