日本有码中文字幕视频,在线能看三级网站,日本妇乱子伦视频免费的,中文字幕一页在线

      首頁生活>內(nèi)容

      什么是堆棧(進(jìn)棧出棧順序圖解)

      時間:2022-11-03 04:41:33來源:
      導(dǎo)讀堆棧介紹Stack也叫棧,是一個線性表,操作有限。限制線性表只能在頁腳插入和刪除。一端稱為棧頂,另一端稱為棧底。向堆棧中插入新元素也稱為push、push或pu

      堆棧介紹

      Stack也叫棧,是一個線性表,操作有限。限制線性表只能在頁腳插入和刪除。一端稱為棧頂,另一端稱為棧底。向堆棧中插入新元素也稱為push、push或push。它把新元素放在堆棧的頂部,使它成為一個新的頂部元素。從堆棧中刪除一個元素也稱為創(chuàng)建堆?;虺蜂N堆棧。就是刪除棧頂元素,使其相鄰元素成為新的頂元素。

      堆積圖

      堆積圖

      代碼實現(xiàn)

      /** * All rights Reserved, Designed By https://www.tulingxueyuan.com/* @Title: ArrayStack.java* @Package com.tuling.infix* @Description: * @author 北京圖靈學(xué)院* @date 2019年11月21日* @version V1.0 */package com.tuling.infix;/** * @ClassName: ArrayStack * @Description: * @author 小白 * @date 2019年11月21日 * */public class ArrayStack {private int[] stack;private int count;private int top;/** * 創(chuàng)建一個新的實例 ArrayStack. * */public ArrayStack() {this(10);}/** * 創(chuàng)建一個新的實例 ArrayStack. * * @param count */public ArrayStack(int count) {this.count = count;stack = new int[count];top = -1;}/*** * @Title: push* @Description:入棧 * @param data * @return void * @throws*/public void push(int data) {if(isFull()) {throw new IllegalArgumentException("棧溢出!");}stack[ top] = data;}/*** * @Title: show* @Description:顯示棧內(nèi)的所有數(shù)據(jù) * @param * @return void * @throws*/public void show() {if(isEmpty()) {throw new IllegalArgumentException("棧為空!");}//從棧頂開始展示for(int i = top; i
      標(biāo)簽: