栈 队列 递归

//2.栈和队列
//。栈 :数据先进后出 犹如弹夹 双向链表实现 栈
//队列 :数据先进先出 好似排队 双向链表实现 队列
// 1:24 数组实现栈 队列
//栈和堆常见面试提
// 实现栈的基本功能基础上 在实现返回栈中最小元素功能
// 1.pop push getMin 操作时间复杂度0(1)2.设计栈类型可以 使用现成的栈结构

//1.用栈结构实现队列结构  2.用队列结构实现栈结构
//2.递归      从思想上理解递归    从实际实现的角度出发理解递归
  //递归函数在系统上 怎么实现的? 递归实际利用的是系统栈  递归函数的 参数 变量 放到系统栈里

//求arr中的最大值
@Test
public void getMax( ){

// int[] arr=new int[4];
int[] arr={1,2,3};
System.out.println( process(arr,0,arr.length-1));
System.out.println(0+(8>>1));
}

public int process(int []arr,int L,int R){
    if(L==R){
        return  arr[L];
    }

// for(int i=L…){
// System.;
// }
int mid=L+((R-L)>>1);//中点
int leftMax=process(arr,L,mid);
int rightMax=process(arr,mid+1,R);
return Math.max(leftMax,rightMax);
}

//哈希表hashMap 有序表TreeMap的用法
//哈希表hashMap 曾 删 改 查  时间复杂度o(1)
//哈希表TreeMap 曾 删 改 查  时间复杂度o(logN)
//hashMap  大类型 Integer map.(Integer,string)  Integer 按值传递
public void hsahMapAndSortTest(){

}

猜你喜欢

转载自blog.csdn.net/qq_34690003/article/details/130647258