面經 煉錶筆試題

2021-08-17 22:30:43 字數 1455 閱讀 6358

鍊錶的基本題型主要就以下這幾種,其他的基本是在這基礎上引申出來,所以如果基本掌握這幾種單向鍊錶的題,鍊錶基本沒什麼太大問題了。

1.刪除無頭非尾節點 

2.鍊錶的氣泡排序

3.反轉鍊錶 

4.在當前節點前插入乙個資料x 

5.查詢鍊錶的中間節點。 

6.刪除單鏈表的倒數第k個節點(k>1&&k《總長度)

對於上面這6個問題,我們進行分析與解答。

void delnothead(node* pos)

void bubblesort(plinklist plist)

while (cur != tail) //當尾指標不等於頭指標時進行冒泡

}

這樣我們就可以實現在當前節點前插入乙個節點了。

煉錶筆試題

反轉鍊錶 節點 class node object def init self,elem self.elem elem self.next none 鍊錶 class singlelist object def init self,head self.head head 反轉鍊錶 defrevers...

鍊錶筆試面試題

有些許錯誤,第乙個程式 1.已知鍊錶的頭結點head,寫乙個函式把這個鍊錶逆序 cpp view plain copy void list reverse head next null head p 遞迴方法 cpp view plain copy void list reverse2 list n...

煉錶筆面問題

下面是幾個常見的煉錶筆面問題 toc 很簡單 複雜度o n int list len node t head 測試 int main int argc,const char argv c b a printf d n list len a 4 return 0 我們多用幾個指標就可以在o n 完成反...