algorithms

Graphs and Paths

This is my summary of the Graphs and Paths chapter. All code is written in c# (converted from java).

Types of Graphs (E - Edges, V - Vertices)
Unweighted: O(|E|) Breadth-first search
Weighted, no negative edges: O(|E| log|V|) Dijkstra's algorithm
Weighted, negative edges: O(|E| * |V|) Bellman-Ford algorithm
Weighted, acyclic: O(|E|) Uses topological sort

A class to represent the Edges:

using System;
using System.Collections;
using System.Collections.Generic;

	public class Edge
	{
		public Vertex dest; // Second vertex in Edge

Singly/Sorted Linked Lists

I am rereading some chapters in "Data Structures & Problem Solving Using Java". I just finished reading chapter 17 on linked lists. Here is the singly linked list and sorted linked list from this chapter done in c#.

LinkedList - the list itself
SortedLinkedList - the sorted linked list
ListNode - represents the node
LinkedListIterator - represents the position

using System;
using System.Collections.Generic;

namespace LinkedLists
{
	public class ListNode
	{
		private T elem;
		private ListNode nextNode;
		
		public T Element
		{
Syndicate content