Coder Social home page Coder Social logo

datastructure's People

Watchers

 avatar

datastructure's Issues

linked list

struct node {
int entery;
node *next;

};

class list {
private:
struct Node {
int entry;
Node* next;
};
Node head;
Node
*tail;

public:
list() {

}


void Firstinsert(Node* head, int a) {
	head->entry = a;
	head->next = NULL;

}
void newinsert(int a, Node *&head) {
	Node *p = new Node;
	p->entry = a;
	p->next = NULL;
	Node *q = head;
	while (q != NULL) {
		if (q->next == NULL) {
			q->next = p;
			return;
		}
		q = q->next;
	}
}

bool deletenode(Node *p, Node *&head) {
	if (p == NULL) {
		cout << "the node you wanna to delet is not found";
		return false;
	}
	if (p == head) {
		head = p->next;
		delete p;
		cout << "we have delete the first node succefully";
		return true;

	}
	Node *q = head;
	while (q) {
		if (q->next == p) {
			q->next = p->next;
			delete p;
			return true;
		}
		q = q->next;
	}
	return false;
}

};

queue

struct node {
int entery;
node *next;

};
class queue {
private:
node *front;
node *last;
int size;

public:
queue() {
front = NULL;
last = NULL;
size = 0;

}

void enqueue(int data) {

	node *p = new node;
	if (size == 0) {
		front = p;
		last = p;
	}
	p->entery = data;
	p->next = last->next;
	last->next = p;


	last = p;
	size++;
}

void dequeue() {
	node *q;
	q = front;
	if (size != 0) {
		front = q->next;
		int num = q->entery;
		delete q;
		size--;
		cout << num << endl;
	}
}
void display() {
	node *p;
	p = front;
	for (int i = 1; i <= size; i++) {
		cout << p->entery << endl;
		p = p->next;

	}
	cout << endl;







}

};

Stack

struct node {
int entery;
node *next;

};
//////////////////////////////////////////////////////////////////////////////////////////////////////
class stack {
private: int siez;
node *head;

public:

stack() {
	siez = 0;
	head = NULL;
}
bool isemputy() {
	if (siez == 0) return true;
	else return false;

}
int resiez() {
	return siez;
}

void push(int a) {
	node *p = new node;
	p->entery = a;
	p->next = head;
	head = p;

	siez++;
}

void pop() {
	node *q = new node;
	q = head;
	head = q->next;
	cout << q->entery << endl;
	delete q;
	siez--;
}

void display() {
	node *q = new node;
	q = head;
	for (int i = 0; i < siez; i++) {
		cout << q->entery << " ";
		q->next = q->next->next;

	}
	cout << endl;
}

};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.