![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 77
飞翔的黄瓜
这个作者很懒,什么都没留下…
展开
-
队列的动态数组实现
#include "Queue.h"#include /* Queue implementation is a dynamically allocated array *//* 用一个动态数组来实现队列 */struct QueueRecord{ int Capacity; int Front; int Rear; int Size; Elem转载 2017-05-27 17:17:20 · 570 阅读 · 0 评论 -
哈希表的一些基本操作
1.线性探测之平方探测法#define MAXTABLESIZE 100000 /* 允许开辟的最大散列表长度 */typedef int ElementType; /* 关键词类型用整型 */typedef int Index; /* 散列地址类型 */typedef Index Position; /* 数据所在位置与散列地址是同一类型 *//* 散原创 2017-07-05 13:48:32 · 773 阅读 · 0 评论 -
关于二叉搜索树的一些操作
#include "stdafx.h"#include "iostream"#include "stdlib.h"#define ElementType inttypedef struct TreeNode *tree;struct TreeNode{ElementType Date;tree Left;tree Right;};tree MakeEmpty(tree T);原创 2017-06-14 16:34:29 · 202 阅读 · 0 评论 -
5-4 是否同一棵二叉搜索树 (25分)
5-4 是否同一棵二叉搜索树 (25分)给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两原创 2017-06-15 10:24:28 · 273 阅读 · 0 评论 -
PAT 电话聊天狂人
看到一个人的解题思路,学到了他的算时间的一种方法,特记录一下11-散列1 电话聊天狂人 (25分)给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。输入格式:输入首先给出正整数N(≤105),为通话记录条数。随后N行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。输出格式:在转载 2017-07-13 09:34:48 · 438 阅读 · 0 评论 -
优先队列priority_queue 用法详解
priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式,不过它可以按照自定义的一种方式(数据的优先级)来对队列中的数据进行动态的排序每次的push和pop操作,优先队列都会动态的调整,以达到我们预期的方式来存储。例如:我们常用的操作就是对数据排序,优先队列默认的是数据大的优先级高转载 2017-07-23 16:22:45 · 1021 阅读 · 0 评论 -
PTA—11-散列4 Hashing - Hard Version (30分)
代码有问题 先存着#include "StdAfx.h"#include #include #include #include using namespace std; #define MAX 1000struct HashNode { int seq; int Key; int indegree; friend bool operat原创 2017-07-23 21:57:26 · 1054 阅读 · 0 评论 -
两个有序链表序列的合并 PAT
关于这道题按照我最开始的思路写下去遇到了两个问题。问题一: 我并没有先创建一个链表就直接调用了Insert()功能,导致我自己赋值的链表list1 list2一直未赋初值,编译时报错list1 list2未赋值后,我给初值NULL运行到Insert()内部也会报错 这里贴错误代码 int main(){ int a[]={1,3,5,7,9};原创 2017-05-24 09:46:56 · 476 阅读 · 0 评论 -
lintcode翻转链表
翻转链表 描述 笔记 数据 评测翻转一个链表您在真实的面试中是否遇到过这个题? Yes样例给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null挑战 标签 相关题目 分析:使用额外两指针方法,只用遍历一次链表即可,且额外控件原创 2017-08-28 17:33:34 · 296 阅读 · 0 评论 -
PAT 1078. Hashing (25)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be "H(key) = key %原创 2017-07-05 12:36:21 · 168 阅读 · 0 评论 -
Tree Traversals Again (PAT) - 树的遍历问题
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac原创 2017-06-13 14:18:14 · 215 阅读 · 0 评论 -
关于AVL平衡二叉树的c语言实现(函数内部改变指针本身)
最近在看数据结构就用c语言写了一个AVL树出来,结果可以运行但无结果输出,搜索许多资料后发现是指针传递的问题,这里总结一下。头文件(修改后的代码)#ifndef __ggh#define __gghtypedef int ElementType;typedef struct AVLTreeNode *AVLTree,*Position;struct AVLTreeNode{ El原创 2017-05-10 15:14:03 · 379 阅读 · 0 评论 -
浙大PAT 1064. Complete Binary Search Tree
064. Complete Binary Search Tree (30)时间限制100 ms内存限制32000 kB代码长度限制16000 B判题程序Standard作者A Binary Search Tree (BST) is recurs转载 2017-06-20 16:10:17 · 189 阅读 · 0 评论 -
二叉堆的一些基本操作(未完待续)
#include "stdafx.h"#include "iostream"#include "stdlib.h"typedef int ElementType;typedef struct HNode *Heap;typedef Heap MaxHeap;struct HNode{ElementType *Date;int Size;int Capti原创 2017-06-22 14:42:50 · 411 阅读 · 0 评论 -
05-树9 Huffman Codes (30分)
05-树9 Huffman Codes (30分)In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redundancy Codes", and hence printed his name in the history of computer scie转载 2017-07-01 14:22:18 · 757 阅读 · 1 评论 -
数据结构-算法-时间复杂度计算
算法的时间复杂度定义为:在进行算法分析时,语句总的执行次数T(n)是关于问题规模n的函数,进而分析T(n)随n的变化情况并确定T(n)的数量级。算法的时间复杂度,也就是算法的时间量度,记作:T(n}=0(f(n))。它表示随问题规模n的增大,算法执行时间的埔长率和 f(n)的埔长率相同,称作算法的渐近时间复杂度,简称为时间复杂度。其中f( n)是问题规横n的某个函数。根据定义,转载 2017-07-01 17:43:38 · 793 阅读 · 0 评论 -
树8 堆中的路径 (25分)
将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。 输入格式:每组测试第1行包含2个正整数NNN和MMM(≤1000\le 1000≤1000),分别是插入元素的个数、以及需要打印的路径条数。下一行给出区间[-10000, 10000]内的NNN个要被插入一个初始为空的小顶堆的整数。最后一行给出MMM个下标。 输出格式:转载 2017-06-22 15:00:15 · 274 阅读 · 0 评论 -
剑指offer 链表的建立等基本操作
#include "stdafx.h"#include "stdlib.h"#include "windows.h"#include "iostream"#include "stack"struct ListNode{int m_value;ListNode *m_pnext;};void AddTOTail(ListNode** L,int x)//用二级指针出了函数L依然为空原创 2017-06-23 13:27:25 · 182 阅读 · 0 评论 -
树2. List Leaves(树的遍历,队列的简单应用)
首先参考ice_camel的博客,其实现方式非常简洁便于理解题目要求Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one转载 2017-06-13 10:47:15 · 432 阅读 · 0 评论 -
经典数据结构-红黑树详解(无代码形式)
介绍:红黑树(Red Black Tree) 是一种自平衡二叉查找树,是在计算机科学中用到的一种数据结构,典型的用途是实现关联数组。它是在1972年由Rudolf Bayer发明的,当时被称为平衡二叉B树(symmetric binary B-trees)。后来,在1978年被 Leo J. Guibas 和 Robert Sedgewick 修改为如今的“红黑树”。红转载 2017-09-25 09:25:48 · 254 阅读 · 0 评论