数据结构算法 两线性表A,B求交集。。。请高手指点!!!

数据结构算法 两线性表A,B求交集。。。请高手指点!!!
已知按值递增有序排练的两个线性表A和B,且每个线性表内部各元素互不相同。试构造线性表C,使其是A和B的交集,且其中的数字同样按值递增排列。 要求: 1)分别采用顺序表、单链表、双链表三种数据结构存储上述线性表A、B、C 2)编写一个通用的程序(无论线性表A、B和C采用顺序表、单链表还是双链表存储,该程序完全通用),实现对线性表C的构造-Known to increase the value ordered by the two linear tables A rehearsal and B, and each of the elements within the linear table from each other. Linear table test structure C, it is the intersection of A and B, and the same number of them increasing order by value. Requirements: 1) were used to order table, a single list, double-linked list data structure stored in the linear three tables A, B, C 2) write a generic program (either the linear form A, B and C using the order form, a single list, or double-linked list storage, the program is completely general), to achieve the construction of the linear form C
flyinthewater 1年前 已收到1个回答 举报

燕子翻飞 幼苗

共回答了21个问题采纳率:95.2% 举报

将A与B分别排序,然后求交。
例如:将A与B按升序排列,设A表头为P,B表头为Q,若A[P]>B[Q]那么Q++,若A[P]

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.691 s. - webmaster@yulucn.com