由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请问一道面试题
相关主题
请教amazon面试题leetcode Copy List with Random Pointer
一道C面试题[合集] 公布几道变态的面试题。
amazon一道面试题[合集] Amazon Onsite 面试题
请教个面试题面试题
请教一道面试题MS面试题
求教一道经典面题的解法BST面试题
请教一个C++问题一道面试题
LeetCode 新题 graph clone一个GOOG的二叉树面试题
相关话题的讨论汇总
话题: list话题: nodes话题: node话题: file话题: link
进入JobHunting版参与讨论
1 (共1页)
d***8
发帖数: 1552
1
Implement a program in C/C++ to serialize one or more link lists in the
file on disk which will let user perform following operations through
command line:
- Add a new list
- Display a given list
- Add a node to any given list
- Remove a node from a list
- Remove a list
- Exit program
Additional requirements:
- Provide optimal solution. Always read and update the file as and when
necessary, to avoid in-memory foot print.
- Nodes can be added in between any of the link lists, keep the link
lists sorted. There is no upper bound to the no. of nodes in a list.
- Reuse deleted node space from other linked list when adding new nodes
- Don't use stl list or third party libraries for serialization
Assumptions:
- All nodes are of same size for simplicity. Node in the list contains
integer data.
- Each list has an integer ID to identify it.
- Use single or double link list as appropriate (do not use STL)
- For simplicity leave the file fragmented when nodes or link list is
deleted
Submit completed project in running state. Submit the design write up
and test cases that you ran for the test.
d***8
发帖数: 1552
2
主要不太清楚应该怎么在文件里存储这些linked list.
请大虾指教。
谢谢!
c***2
发帖数: 838
3
Depending on the data type: either text or binary
Also you may need to build another list to retrieve the list info.
Is this an interview question or a homework? :-)

【在 d***8 的大作中提到】
: 主要不太清楚应该怎么在文件里存储这些linked list.
: 请大虾指教。
: 谢谢!

d***8
发帖数: 1552
4
能展开说说吗?
怎么存储链表里的data和next指针?
another list 是作什么用的?
多谢!
这是一道面试题。他让我周末作完发给他。

【在 c***2 的大作中提到】
: Depending on the data type: either text or binary
: Also you may need to build another list to retrieve the list info.
: Is this an interview question or a homework? :-)

c***2
发帖数: 838
5
First of all, this is not a good project: a lot of work without any
technical difficulty
If you really want/need to do it, here are some ideas:
1) how to store list in file using simple text
list#
list-length
list-contents
no need to store address, when read a list, just re-construct it
2) to get a speficied list from file:
read list#, if match, read and construct it
otherwise, read next list or till eof
3) to modify a list:
for example. modify list#5

copy lists1-4 to another file
write #5
copy rest of it
replace file
4) other operations are simple


c***2
发帖数: 838
6
Here's an example:
Just replace stock industry with a list number
replace stock tickers with integers
Financial - PropertyCasualtyInsurance
2
AIG
HIG
Financial - AssetManagement
1
AMP
Services - ApparelStores
4
ANF
ANN
FL
ROST
Financial - RegionalMidAtlanticBanks
2
BBT
WL
1 (共1页)
进入JobHunting版参与讨论
相关主题
一个GOOG的二叉树面试题请教一道面试题
请问一个简单的面试题求教一道经典面题的解法
请教一道面试题请教一个C++问题
Amazon面试题请教LeetCode 新题 graph clone
请教amazon面试题leetcode Copy List with Random Pointer
一道C面试题[合集] 公布几道变态的面试题。
amazon一道面试题[合集] Amazon Onsite 面试题
请教个面试题面试题
相关话题的讨论汇总
话题: list话题: nodes话题: node话题: file话题: link