数据结构基础(严蔚敏)
线性表之数组
public class ArrayOpt {public static void main(String[] args) {//数组逆序int [] a = {1,2,3,4,5,6,7,8,9,10,11};int[] f = deleteArray(a,7);for (int k:f) {System.out.print(k+",");}}//遍历反转public static int[] reverseArray(int[] a){if(a.length==0){System.out.print("This is null Array \n");return a;}int [] b = new int[a.length];for(int i =0;i<a.length;i++){b[i] = a[(a.length-1)-i];}return b;}//二分交换反转public static int[] reverseArray1(int[] a){if(a.length==0){System.out.print("This is null Array \n");return a;}for(int i=0;i<a.length/2;i++){int temp = a[i];a[i] = a[(a.length-1)-i];a[(a.length-1)-i] = temp;}return a;}//数组的增加public static int[] insertElement(int[]a,int loc,int e){if(loc<=0||loc>a.length){System.out.print("index IndexOutOfBoundsException,souf original aar \n");return a;}int []aar = new int[a.length+1];//因为下标从0开始,所以loc-1System.arraycopy(a, 0, aar, 0, loc - 1);aar[loc-1] = e;System.arraycopy(a, loc - 1, aar, loc, a.length - (loc - 1));return aar;}//数组的删除public static int[] deleteArray(int[] a, int loc){if(loc<=0||loc>a.length){System.out.printf("index IndexOutOfBoundsException,souf original aar \n");return a;}int [] aar = new int[a.length-1];System.arraycopy(a,0,aar,0,loc-1);System.arraycopy(a,loc,aar,loc-1,a.length-loc);return aar;}//数组的修改public int[] undateArray(int[] a,int loc,int data){if(loc<=0||loc>a.length){System.out.print("index IndexOutOfBoundsException,souf original aar \n");return a;}a[loc] = data;return a;}//数组的查找public boolean searchArray(int[] a,int date){for (int j : a) {if (j == date)return true;}return false;}}
数据结构基础(严蔚敏)相关推荐
- Dijkstra 算法-《数据结构》严蔚敏
应用介绍 假定某个销售做年度出差计划,每次需要从固定城市出发,去其它城市推销产品,那么问题就来了,如果求得从固定城市到其它拜访城市的最短路径或最小时间呢? 这就是一个典型的Dijkstra求解问题. ...
- 数据结构:严蔚敏、殷人昆快速排序规则不同的疑问
快速排序 Partition 过程:将要排序的数据分成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小.快速排序整个排序过程可以递归进行,以此达到整个数据变成有序序列. 注:408原题 ...
- 《数据结构》严蔚敏与陈越伪代码总结
1 //陈 2 typedef struct LNode *List;3 struct LNode{4 int Data[MaxSize];//如果放多个元素,这个可改为指针,在初始化中指向数组 5 ...
- 数据结构(严蔚敏)的一些排序算法源代码
最近找工作时经常会被问到各种排序算法,现在把严蔚敏书中的排序算法摘抄出来,以便随时学习,顺便测试下windows live writer的代码着色插件是否好用 1.InsertSort直接插入排序 隐 ...
- 《数据结构与算法基础 严蔚敏版》第一章 绪论
菜鸟笔记,不定时更新... 链接:https://pan.baidu.com/s/1z-kFKiNaezO0k2BWQ8l1Hw 提取码:asdf 一.数据结构的基本概念: 1.数据.数据元素.数据 ...
- 《数据结构与算法基础 严蔚敏版》第三章 堆栈与队列
链接:https://pan.baidu.com/s/1z-kFKiNaezO0k2BWQ8l1Hw 提取码:asdf 1.堆栈 (1)堆栈的概念 栈:只允许在一段进行插入或删除操作的线性表 栈顶: ...
- 数据结构(严蔚敏)之四——链栈之c语言实现
编写一个程序实现链栈的各种基本运算,并在此基础上设计一个主程序,完成如下功能: (1)初始化链栈 (2)链栈置空 (3)入栈 (4)出栈 (5)取栈顶元素 (6)遍历链栈 链栈的功能实现: #incl ...
- 数据结构(严蔚敏)之三——顺序栈之c语言实现
实验: 编写一个程序实现顺序栈的各种基本运算,并在此基础上设计一个主程序,完成如下功能: (1)初始化顺序栈 (2)插入元素 (3)删除栈顶元素 (4)取栈顶元素 (5)遍历顺序栈 (6)置空顺序栈 ...
- 数据结构(严蔚敏)之六——链式队列c语言实现
实验: 编写一个程序实现链队列的各种基本运算,并在此基础上设计一个主程序,完成如下功能: (1)初始化并建立链队列 (2)入链队列 (3)出链队列 (4)遍历链队列 分析: 队列的链式存储结构简称为链 ...
- 《数据结构》严蔚敏第二版 2.53 循环链表,双向链表
ps:我现在是大二上,这个学期修数据结构,知识点是我上课,下课在书上,网上各种地方找到理解了之后写出来的这些东西,可能会有错误(请C友们指正),这个学期会把数据结构更新完,一些比较简单的增删改查我第一 ...
最新文章
- MySQL 用户与授权管理详解
- Springboot 利用CORS 解决跨域问题
- sudo with no password
- 聊聊 Java 的几把 JVM 级锁
- 从编解码算法到全链路RTC架构,揭秘淘系直播技术演进之路
- 办公效率:从事会计行业,这些Excel技巧绝对用得着!
- 网络操作系统第242页作业
- MFC下列表控件的使用
- ReportViewer中设置ServerReport.ReportServerCredentials属性的方法(WEB版)
- 库克看下!罗永浩深夜再谈收购苹果:还需要点时间
- Mac安装telnet
- 今日恐慌与贪婪指数为94 贪婪程度有所上升
- swing的jlist的值怎么获取_彻底解决安卓/IOS获取蓝牙ID不一致的问题
- 排序-InsertionSort 插入排序
- 巧用Delphi制作溅射屏幕
- SHELL编程基础之BASH入门
- atlas怎么看日志_[系列文章] Gin框架 - 使用logrus日志记录
- DELPHI利WMI获得硬盘参数
- android 判断手机计步_Android_基于G-Sensor的计步算法
- 创业36条军规值得一读